assets
1 year ago
views
1 year ago
Api.php
1 year ago
Import.php
1 year ago
Init.php
1 year ago
Load.php
1 year ago
Init.php
82 lines
| 1 | <?php |
| 2 | namespace SPEL\includes\template_library; |
| 3 | |
| 4 | defined('ABSPATH') || die(); |
| 5 | |
| 6 | class Init { |
| 7 | private static $instance = null; |
| 8 | |
| 9 | public static function url(){ |
| 10 | return trailingslashit(plugin_dir_url( __FILE__ )); |
| 11 | } |
| 12 | |
| 13 | public static function dir(){ |
| 14 | return trailingslashit(plugin_dir_path( __FILE__ )); |
| 15 | } |
| 16 | |
| 17 | public static function version(){ |
| 18 | return '1.0.0'; |
| 19 | } |
| 20 | |
| 21 | public function init(): void |
| 22 | { |
| 23 | |
| 24 | add_action( 'wp_enqueue_scripts', function() { |
| 25 | wp_enqueue_style( "docy-core-template-front", self::url() . 'assets/css/template-frontend.min.css' , ['elementor-frontend'], self::version() ); |
| 26 | } |
| 27 | ); |
| 28 | |
| 29 | add_action( 'elementor/editor/after_enqueue_scripts', function() { |
| 30 | wp_enqueue_style( "docy-load-template-editor", self::url() . 'assets/css/template-library.min.css' , ['elementor-editor'], self::version() ); |
| 31 | wp_enqueue_script("docy-load-template-editor", self::url() . 'assets/js/template-library.min.js', ['elementor-editor'], self::version(), true); |
| 32 | $pro = get_option('__validate_author_dtaddons__', false); |
| 33 | |
| 34 | $localize_data = [ |
| 35 | 'hasPro' => !$pro ? false : true, |
| 36 | 'templateLogo' => DOCY_TEMPLATE_WHITE_LOGO_SRC, |
| 37 | 'i18n' => [ |
| 38 | 'templatesEmptyTitle' => esc_html__( 'No Templates Found', 'spider-elements' ), |
| 39 | 'templatesEmptyMessage' => esc_html__( 'Try different category or sync for new templates.', 'spider-elements' ), |
| 40 | 'templatesNoResultsTitle' => esc_html__( 'No Results Found', 'spider-elements' ), |
| 41 | 'templatesNoResultsMessage' => esc_html__( 'Please make sure your search is spelled correctly or try a different words.', 'spider-elements' ), |
| 42 | ], |
| 43 | 'tab_style' => json_encode(self::get_tabs()), |
| 44 | 'default_tab' => 'page' |
| 45 | ]; |
| 46 | wp_localize_script( |
| 47 | 'docy-load-template-editor', |
| 48 | 'docyEditor', |
| 49 | $localize_data |
| 50 | ); |
| 51 | |
| 52 | }, |
| 53 | 999 |
| 54 | ); |
| 55 | |
| 56 | add_action( 'elementor/preview/enqueue_styles', function(){ |
| 57 | $data = '.elementor-add-new-section .docy_templates_add_button { |
| 58 | background-color: #6045bc; |
| 59 | margin-left: 5px; |
| 60 | font-size: 18px; |
| 61 | vertical-align: bottom; |
| 62 | } |
| 63 | '; |
| 64 | wp_add_inline_style( 'docy-core-template-front', $data ); |
| 65 | }, 999 ); |
| 66 | } |
| 67 | |
| 68 | public static function get_tabs() { |
| 69 | return apply_filters('docy_editor/templates_tabs', [ |
| 70 | 'section' => [ 'title' => 'Docy Blocks'], |
| 71 | 'page' => [ 'title' => 'Docy Pages'], |
| 72 | ]); |
| 73 | } |
| 74 | public static function instance(){ |
| 75 | if( is_null(self::$instance) ){ |
| 76 | self::$instance = new self(); |
| 77 | } |
| 78 | return self::$instance; |
| 79 | } |
| 80 | } |
| 81 | |
| 82 |