-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-calculator.php
118 lines (100 loc) · 3.15 KB
/
wp-calculator.php
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
/**
* Plugin Name: Kanzu Calculator
* Plugin URI: https://kanzucode.com
* Description: A sample WordPress plugin to illustrate automated testing using Codeception
* Version: 1.0.0
* Author: Kanzu Code
* Author URI: https://kanzucode.com
* Requires PHP: 7.0
* Text Domain: kz-wp-calculator
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Domain Path: /languages
*/
if (! defined('ABSPATH')) {
exit;
} // End if().
if (! class_exists('Kanzu_WP_Calculator')) {
final class Kanzu_WP_Calculator
{
/**
* Reference to plugin version
*
* @var string
*/
public $version = '1.0.0';
/**
* Variable that holds the one and only instance of the calculator
*
* @var Kanzu_WP_Calculator
*/
private static $_instance = null;
/**
* Load the global Calculator instance
*
* @return Kanzu_WP_Calculator
*/
public static function get_instance()
{
if (is_null(self::$_instance)) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Cloning is forbidden.
*
* @since 1.8.0
*/
public function __clone()
{
_doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'kz-wp-starter-plugin'), $this->version);
}
/**
* Unserializing instances of this class is forbidden.
*
* @since 1.8.0
*/
public function __wakeup()
{
_doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'kz-wp-starter-plugin'), $this->version);
}
public function __construct()
{
$this->define_constants();
$this->includes();
}
private function define_constants()
{
$this->define('KZ_WP_CALCULATOR_PLUGIN_VERSION', $this->version);
$this->define('KZ_WP_CALCULATOR_PLUGIN_DIR', plugin_dir_path(__FILE__));
$this->define('KZ_WP_CALCULATOR_PLUGIN_URL', plugin_dir_url(__FILE__));
$this->define('KZ_WP_CALCULATOR_PLUGIN_PLUGIN_FILE', __FILE__);
}
/**
* Define constant if not already set.
*
* @param string $name
* @param string|bool $value
*/
private function define($name, $value)
{
if (! defined($name)) {
define($name, $value);
}
}
private function includes()
{
require_once KZ_WP_CALCULATOR_PLUGIN_DIR . '/vendor/autoload.php';
require_once ( KZ_WP_CALCULATOR_PLUGIN_DIR . '/includes/class-scripts.php');
require_once ( KZ_WP_CALCULATOR_PLUGIN_DIR . '/includes/class-calculator.php');
require_once ( KZ_WP_CALCULATOR_PLUGIN_DIR . '/includes/class-hook-registry.php');
}
}
function Kanzu_WP_Calculator()
{
return Kanzu_WP_Calculator::get_instance();
}
Kanzu_WP_Calculator();
}// End if().