-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsquare.php
More file actions
123 lines (110 loc) · 2.68 KB
/
square.php
File metadata and controls
123 lines (110 loc) · 2.68 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
119
120
121
122
123
<?php
/*
Plugin Name: Square
Plugin URI: https://github.com/johnnyicarus/square
Description: A WordPress mu-plugin which contains a collection of modules to apply theme-agnostic back-end modifications.
Version: 0.0.4
Author: Formwerdung
Author URI: http://formwerdung.ch
License: MIT License
License URI: http://opensource.org/licenses/MIT
*/
namespace Formwerdung;
class Square {
/**
* Plugin requires php version
*
* @access public
* @var string
*/
public $required_php_version = '5.4';
/**
* Plugin requires WordPress version
*
* @access public
* @var string
*/
public $required_wp_version = '4.2.4';
/**
* Is the requirements problem php
*
* @access public
* @var bool
*/
public $is_problem_php = false;
/**
* Constructor, pass to bootstrapper
*
* @since 0.0.1
* @access public
*/
public function __construct() {
$this->bootstrap();
}
/**
* Bootstrapper, loads all the files that are required anyway
* and the module loader for further checking of features
*
* @since 0.0.1
* @access private
* @uses add_action()
*/
private function bootstrap() {
if ($this->requirementsMet($this->required_php_version, $this->required_wp_version)) {
require_once('lib/utils.php');
require_once('lib/module.php');
require_once('lib/admin.php');
require_once('lib/dashboard_widget.php');
require_once('modules.php');
$modules = new Square\Modules();
} else {
add_action('admin_notices', [$this, 'requirementsError']);
}
}
/**
* Include requirement error view
*
* @since 0.0.5
* @access public
* @uses $wp_version global string
*/
public function requirementsError() {
global $wp_version;
include_once('views/requirements_error.php');
}
/**
* Check if php & wp version requirements are met
*
* @since 0.0.1
* @lastchanged 0.0.5
* @access private
* @uses $wp_version global string
* @param $req_php_version string
* @param $req_wp_version string
* @return bool
*/
private function requirementsMet($req_php_version, $req_wp_version) {
global $wp_version;
if (version_compare(PHP_VERSION, $req_php_version, '<')) {
$this->is_problem_php = true;
return false;
}
if (version_compare($wp_version, $req_wp_version, '<')) {
return false;
}
return true;
}
}
/**
* Init function
*
* @since 0.0.1
* @lastchanged 0.0.5
* @access public
*/
if (!function_exists('square_init')) {
function square_init() {
new Square();
}
}
add_action('after_setup_theme', __NAMESPACE__ . '\\square_init');