dist
4 years ago
src
1 month ago
Makefile
4 years ago
loader.php
1 month ago
webpack.config.js
4 years ago
loader.php
67 lines
| 1 | <?php |
| 2 | |
| 3 | $otg_ui_version = 11000; |
| 4 | |
| 5 | |
| 6 | global $otg_ui_versions; |
| 7 | |
| 8 | if ( ! isset( $otg_ui_versions ) ) { |
| 9 | $otg_ui_versions = array(); |
| 10 | } |
| 11 | |
| 12 | if ( ! isset( $otg_ui_versions[ $otg_ui_version ] ) ) { |
| 13 | $otg_ui_versions[ $otg_ui_version ] = array( |
| 14 | 'path' => wp_normalize_path( __DIR__ ), |
| 15 | ); |
| 16 | } |
| 17 | |
| 18 | |
| 19 | if ( ! function_exists( 'otgs_ui_initialize' ) ) { |
| 20 | |
| 21 | function otgs_ui_initialize( $vendor_path, $vendor_url ) { |
| 22 | global $otg_ui_versions; |
| 23 | |
| 24 | if ( is_link( $vendor_path ) ) { |
| 25 | $vendor_path = readlink( $vendor_path ); |
| 26 | } |
| 27 | |
| 28 | $vendor_path = wp_normalize_path( $vendor_path ); |
| 29 | $vendor_path = untrailingslashit( $vendor_path ); |
| 30 | $vendor_url = untrailingslashit( $vendor_url ); |
| 31 | |
| 32 | foreach ( $otg_ui_versions as $version => $data ) { |
| 33 | if ( $otg_ui_versions[ $version ]['path'] === $vendor_path ) { |
| 34 | $otg_ui_versions[ $version ]['url'] = $vendor_url; |
| 35 | break; |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | if ( ! function_exists( 'otgs_ui_plugins_loaded' ) ) { |
| 42 | function otgs_ui_plugins_loaded() { |
| 43 | global $otg_ui_versions; |
| 44 | |
| 45 | $latest = 0; |
| 46 | foreach ( $otg_ui_versions as $version => $data ) { |
| 47 | if ( $version > $latest ) { |
| 48 | $latest = $version; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | if ( $latest > 0 && isset( $otg_ui_versions[ $latest ]['url'] ) ) { |
| 53 | require_once $otg_ui_versions[ $latest ]['path'] . '/src/php/OTGS_Assets_Handles.php'; |
| 54 | require_once $otg_ui_versions[ $latest ]['path'] . '/src/php/OTGS_Assets_Store.php'; |
| 55 | require_once $otg_ui_versions[ $latest ]['path'] . '/src/php/OTGS_UI_Assets.php'; |
| 56 | require_once $otg_ui_versions[ $latest ]['path'] . '/src/php/OTGS_UI_Loader.php'; |
| 57 | |
| 58 | $assets_store = new OTGS_Assets_Store(); |
| 59 | $assets = new OTGS_UI_Assets( $otg_ui_versions[ $latest ]['url'] . '/dist', $assets_store ); |
| 60 | $loader = new OTGS_UI_Loader( $assets_store, $assets ); |
| 61 | $loader->load(); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | add_action( 'plugins_loaded', 'otgs_ui_plugins_loaded', -PHP_INT_MAX ); |
| 66 | } |
| 67 |