Skip to content
This repository was archived by the owner on Nov 14, 2024. It is now read-only.

Commit 303d4fd

Browse files
chore(): Release v3.1.0
2 parents 011e694 + 535e81c commit 303d4fd

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

tonik-gin.php

+30-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
Plugin Name: tonik/gin
55
Plugin URI: http://tonik.pl
66
Description: Foundation of the Tonik WordPress Starter Theme. Provides all custom functionalities which it offers.
7+
<<<<<<< HEAD
78
Version: 3.0.0
9+
=======
10+
Version: 3.1.0
11+
>>>>>>> release-3.1.0
812
Author: Tonik
913
Author URI: http://tonik.pl
1014
License: GPL-2.0+
@@ -13,7 +17,30 @@
1317
Text Domain: tonik.gin
1418
*/
1519

16-
if (file_exists($composer = __DIR__ . '/vendor/autoload.php')) {
17-
require $composer;
18-
}
20+
spl_autoload_register(function ($class) {
21+
// Namespace prefix
22+
$prefix = 'Tonik\\';
1923

24+
// Base directory for the namespace prefix
25+
$base_dir = __DIR__ . '/src/';
26+
27+
// Does the class use the namespace prefix?
28+
$len = strlen($prefix);
29+
if (strncmp($prefix, $class, $len) !== 0) {
30+
// No, move to the next registered autoloader
31+
return;
32+
}
33+
34+
// Get the relative class name
35+
$relative_class = substr($class, $len);
36+
37+
// Replace the namespace prefix with the base
38+
// directory, replace namespace separators with directory
39+
// separators in the relative class name, append with .php
40+
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
41+
42+
// If the file exists, require it
43+
if (file_exists($file)) {
44+
require $file;
45+
}
46+
});

0 commit comments

Comments
 (0)