-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsystem.php
More file actions
86 lines (69 loc) · 2.77 KB
/
Copy pathsystem.php
File metadata and controls
86 lines (69 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/**
* The System module is being replaced by new code organization in ../core.php.
*/
use tangible\date;
use tangible\framework;
use tangible\template_system;
if (!function_exists('tangible_template_system')) {
function tangible_template_system( $arg = false ) {
static $o;
return $arg === false ? $o : ( $o = $arg );
}
}
(include __DIR__.'/../module-loader.php')(new class extends \stdClass {
public $name = 'tangible_template_system';
public $version = '20260601';
public $url;
public $path;
public $file_path;
public $has_plugin = [];
function load() {
$this->path = __DIR__;
$this->file_path = __FILE__;
tangible_template_system( $this );
/**
* During plugin activation, the newest version of Framework or other modules is not
* guaranteed due to how WordPress runs the `plugins_loaded` action *before* loading
* plugins and modules, short-circuiting the version comparison logic.
*
* After activation, they are loaded normally. To ensure newest modules, use them
* during or after `plugins_loaded` action.
*
* @see https://developer.wordpress.org/reference/functions/register_activation_hook/#more-information
* @see https://github.com/WordPress/wordpress-develop/blob/8a52d746e9bb85604f6a309a87d22296ce1c4280/src/wp-admin/includes/plugin.php#L2381C10-L2381C31
*/
if (defined('WP_SANDBOX_SCRAPING')) return;
// Keep trailing slash for backward compatibility
$this->url = trailingslashit( framework\module_url( __FILE__ ) );
$system = $plugin = $this;
require_once __DIR__.'/../core.php';
// Backward compatibility
$system->has_plugin = template_system\get_active_plugins();
$ready_hook = "{$system->name}_ready";
do_action( $ready_hook, $system );
remove_all_actions( $ready_hook );
add_action('plugins_loaded', function() use ( $system ) {
// For any callbacks that registered later
do_action( "{$system->name}_ready", $system );
}, 12); // After plugins register
}
function ready( $callback ) {
if ( did_action( "{$this->name}_ready" ) ) {
return $callback( $this );
}
add_action( "{$this->name}_ready", $callback );
}
// Mock $plugin methods during transition from plugin to module
function is_multisite() { return false; }
function get_settings() { return []; }
function update_settings() {}
// Dynamic methods for backward compatibility
function __call( $method = '', $args = [] ) {
if ( isset( $this->$method ) ) {
return call_user_func_array( $this->$method, $args );
}
$caller = current( debug_backtrace() );
trigger_error( "Undefined method \"$method\" for {$this->name}, called from <b>{$caller['file']}</b> on line <b>{$caller['line']}</b><br>", E_USER_WARNING );
}
});