-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShellPress.php
More file actions
118 lines (85 loc) · 2.94 KB
/
ShellPress.php
File metadata and controls
118 lines (85 loc) · 2.94 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
namespace shellpress\v1_4_0;
use shellpress\v1_4_0\src\Shell;
if( ! class_exists( 'shellpress\v1_4_0\ShellPress', false ) ){
/**
* Core class of plugin. To use it, simple extend it.
*/
abstract class ShellPress {
/** @var static */
protected static $_instances = array();
/** @var Shell */
private $_shell;
/**
* Private forbidden constructor.
*/
private final function __construct() {
}
/**
* Gets singleton instance.
*
* @deprecated
*
* @return static
*/
public final static function getInstance() {
return static::i();
}
/**
* Alias for getInstance();
*
* @return static
*/
public final static function i() {
$calledClass = get_called_class();
if( ! isset( static::$_instances[ $calledClass ] ) ){
wp_die( sprintf( 'You need to call %1$s::initShellPress().', $calledClass ) );
}
return static::$_instances[ $calledClass ];
}
/**
* Gets Shell object.
*
* @deprecated
*
* @return Shell
*/
public final static function shell() {
return static::s();
}
/**
* Alias for shell();
*
* @return shell
*/
public final static function s() {
return static::i()->_shell;
}
/**
* Call this method as soon as possible!
*
* @param string $mainPluginFile - absolute path to main plugin file (__FILE__).
* @param string $pluginPrefix - will be used to prefix everything in plugin
* @param string $pluginVersion - set your plugin version. It will be used in scripts suffixing etc.
* @param string|null $softwareType - set type of software. Used for better paths resolving. Nor required.
*/
public static function initShellPress( $mainPluginFile, $pluginPrefix, $pluginVersion, $softwareType = null ) {
static::$_instances[ get_called_class() ] = $instance = new static();
$instance->_shell = new Shell( $mainPluginFile, $pluginPrefix, $pluginVersion, $softwareType );
$instance->_shell->init( $instance );
// ----------------------------------------
// Everything is ready. Call onSetUp()
// ----------------------------------------
static::i()->onSetUp();
}
// ================================================================================
// METHOD STUBS
// ================================================================================
/**
* Called automatically after core is ready.
*
* @return void
*/
protected abstract function onSetUp();
}
}