Skip to content

Commit ce22e89

Browse files
committed
add TypeRocket Engine7 Loader
1 parent d408456 commit ce22e89

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

init.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
do_action('typerocket_engine7_loaded');

loader.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
/**
3+
* Register TypeRocket Engine7
4+
*
5+
* 1. Install TypeRocket Engine7 with composer but do not include the composer autoload.php file.
6+
* 2. Include this file in your plugin.
7+
* 3. Add your TypeRocket code to the action hook typerocket_engine7_loaded
8+
*
9+
* include __DIR__ . '/vendor/typerocket/engine/loader.php';
10+
*
11+
* add_action('typerocket_engine7_loaded', function() {
12+
* // Your code here
13+
* });
14+
*/
15+
if(!function_exists('typerocket_engine7_register')) {
16+
function typerocket_engine7_register(?string $version = null, ?string $location = null) {
17+
static $v = '0:0';
18+
19+
[$number, $directory] = explode(':', $v);
20+
21+
if($version === null) {
22+
return explode(':', $v);
23+
}
24+
25+
$v = max($number, $version);
26+
27+
if($v === $version) {
28+
$v = $v.':'.$location;
29+
} else {
30+
$v = $v.':'.$directory;
31+
}
32+
33+
return $v;
34+
}
35+
36+
add_action('after_setup_theme', function() {
37+
[$number, $directory] = typerocket_engine7_register();
38+
require_once $directory . '/vendor/autoload.php';
39+
require_once $directory . '/init.php';
40+
});
41+
}
42+
43+
typerocket_engine7_register('7.0.0', __DIR__);

0 commit comments

Comments
 (0)