Plugin Directory

source: asin-smart-links/trunk/Includes/Loader.php @ 2928016

Last change on this file since 2928016 was 2928016, checked in by joanrodas, 13 months ago

Update to version 1.0.1 from GitHub

File size: 1.4 KB
Line 
1<?php
2namespace AsinSmartInternationalLinks\Includes;
3
4class Loader
5{
6        protected $plugin_name;
7        protected $plugin_version;
8
9        public function __construct()
10        {
11                $this->plugin_version = defined('ASINSMARTINTERNATIONALLINKS_VERSION') ? ASINSMARTINTERNATIONALLINKS_VERSION : '1.0.0';
12                $this->plugin_name = 'asin-smart-links';
13                $this->load_dependencies();
14
15                add_action('plugins_loaded', [$this, 'load_plugin_textdomain']);
16                add_action('wp_enqueue_scripts', [$this, 'register_scripts']);
17        }
18
19        private function load_dependencies()
20        {
21                foreach (glob(ASINSMARTINTERNATIONALLINKS_PATH . 'Functionality/*.php') as $filename) {
22                        $class_name = '\\AsinSmartInternationalLinks\Functionality\\'. basename($filename, '.php');
23                        if (class_exists($class_name)) {
24                                try {
25                                        new $class_name($this->plugin_name, $this->plugin_version);
26                                }
27                                catch (\Throwable $e) {
28                                        pb_log($e);
29                                        continue;
30                                }
31                        }
32                }
33        }
34
35        public function load_plugin_textdomain()
36        {
37                load_plugin_textdomain('asin-smart-links', false, dirname(ASINSMARTINTERNATIONALLINKS_BASENAME) . '/languages/');
38        }
39
40        public function register_scripts()
41        {
42                wp_register_style( $this->plugin_name . '-styles', ASINSMARTINTERNATIONALLINKS_URL . 'dist/app.css', [], $this->plugin_version, 'all' );
43                wp_register_script( $this->plugin_name . '-script', ASINSMARTINTERNATIONALLINKS_URL . 'dist/app.js', [], $this->plugin_version, 'all' );
44        }
45}
Note: See TracBrowser for help on using the repository browser.