-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathinit.php
More file actions
141 lines (118 loc) · 4.55 KB
/
init.php
File metadata and controls
141 lines (118 loc) · 4.55 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
/**
* Custom Tables Loader
*
* Handles checking for and smartly loading the newest version of this library.
*
* @category WordPressLibrary
* @package Custom_Tables\Loader
* @author GamiPress <contact@gamipress.com>, Ruben Garcia <rubengcdev@gamil.com>
* @copyright GamiPress <contact@gamipress.com>, Ruben Garcia <rubengcdev@gamil.com>
* @credits Justin Sternberg (https://jtsternberg.com), Jhon James Jacob (https://jjj.blog)
* @license GPL-2.0+
* @version 1.0.7
* @link https://gamipress.com
*/
/*
* Copyright (c) GamiPress (contact@gamipress.com), Ruben Garcia (rubengcdev@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2 or, at
* your discretion, any later version, as published by the Free
* Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* Loader versioning: http://jtsternberg.github.io/wp-lib-loader/
*/
if ( ! class_exists( 'CT_Loader_107', false ) ) {
class CT_Loader_107 {
/**
* CT_Loader version number
* @var string
* @since 1.0.0
*/
const VERSION = '1.0.7';
/**
* Setup constants
*
* @since 1.0.0
*/
private function constants() {
// Version
define( 'CT_VER', self::VERSION );
// File
define( 'CT_FILE', __FILE__ );
// Path
define( 'CT_DIR', plugin_dir_path( __FILE__ ) );
// URL
define( 'CT_URL', plugin_dir_url( __FILE__ ) );
// Debug
define( 'CT_DEBUG', false );
}
/**
* Starts the version checking process.
* Creates CT_LOADED definition for early detection by other scripts.
*
* Hooks CT_Loader inclusion to the ct_loader_load hook
* on a high priority which decrements (increasing the priority) with
* each version release.
*
* @since 1.0.0
*/
public function __construct() {
if ( ! defined( 'CT_LOADER_PRIORITY' ) ) {
// Calculate priority converting version into a number (eg: 1.0.0 to 100)
define( 'CT_LOADER_PRIORITY', 99999 - absint( str_replace( '.', '', self::VERSION ) ) );
}
if ( ! defined( 'CT_LOADED' ) ) {
// A constant you can use to check if Custom Tables (CT) is loaded for your plugins/themes with CT dependency.
// Can also be used to determine the priority of the hook in use for the currently loaded version.
define( 'CT_LOADED', CT_LOADER_PRIORITY );
}
// Use the hook system to ensure only the newest version is loaded.
add_action( 'ct_loader_load', array( $this, 'include_lib' ), CT_LOADER_PRIORITY );
// Try to fire our hook as soon as possible,including right now (required for activation hooks).
self::fire_hook();
// Hook in to the first hook we have available and fire our `ct_loader_load' hook.
add_action( 'muplugins_loaded', array( __CLASS__, 'fire_hook' ), 9 );
add_action( 'plugins_loaded', array( __CLASS__, 'fire_hook' ), 9 );
add_action( 'after_setup_theme', array( __CLASS__, 'fire_hook' ), 9 );
}
/**
* Fires the ct_loader_load action hook.
*
* @since 1.0.0
*/
public static function fire_hook() {
if ( ! did_action( 'ct_loader_load' ) ) {
// Then fire our hook.
do_action( 'ct_loader_load' );
}
}
/**
* A final check if CT_Loader exists before kicking off
* our CT_Loader loading.
*
* @since 1.0.0
*/
public function include_lib() {
if ( class_exists( 'CT', false ) ) {
return;
}
$this->constants();
// Include and initiate Custom Tables (CT) class.
require_once CT_DIR . 'includes/class-ct.php';
}
}
// Kick it off.
new CT_Loader_107;
}