PluginProbe
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI / 8.0.1
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI v8.0.1
8.0.1 8.0.2 8.0.0 7.9.9.7 7.9.9.6 7.9.9.5 7.9.9.4 7.9.9.3 7.9.9.2 7.9.9.1 7.9.9 7.9.8 7.9.7 7.9.6 7.9.5 7.9.4 7.9.3 7.9.2 7.9.1 7.9.0 7.8.9 7.8.8 7.8.7 7.8.6 7.8.5 All 44 releases
gamipress / libraries / ct / init.php

init.php in GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI 8.0.1, at libraries/ct/init.php

147 lines 4.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Custom Tables Loader
4 *
5 * Handles checking for and smartly loading the newest version of this library.
6 *
7 * @category WordPressLibrary
8 * @package Custom_Tables\Loader
9 * @author GamiPress <contact@gamipress.com>, Ruben Garcia <rubengcdev@gamil.com>
10 * @copyright GamiPress <contact@gamipress.com>, Ruben Garcia <rubengcdev@gamil.com>
11 * @credits Justin Sternberg (https://jtsternberg.com), Jhon James Jacob (https://jjj.blog)
12 * @license GPL-2.0+
13 * @version 1.1.1
14 * @link https://gamipress.com
15 */
16 // Exit if accessed directly
17 if( !defined( 'ABSPATH' ) ) exit;
18
19 /*
20 * Copyright (c) GamiPress (contact@gamipress.com), Ruben Garcia (rubengcdev@gmail.com)
21 *
22 * This program is free software; you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License, version 2 or, at
24 * your discretion, any later version, as published by the Free
25 * Software Foundation.
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
31 *
32 * You should have received a copy of the GNU General Public License
33 * along with this program; if not, write to the Free Software
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
35 */
36
37 /**
38 * Loader versioning: http://jtsternberg.github.io/wp-lib-loader/
39 */
40 if ( ! class_exists( 'CT_Loader_111', false ) ) {
41
42 class CT_Loader_111 {
43
44 /**
45 * CT_Loader version number
46 * @var string
47 * @since 1.0.0
48 */
49 const VERSION = '1.1.1';
50
51 /**
52 * Setup constants
53 *
54 * @since 1.0.0
55 */
56 private function constants() {
57
58 // Version
59 define( 'CT_VER', self::VERSION );
60
61 // File
62 define( 'CT_FILE', __FILE__ );
63
64 // Path
65 define( 'CT_DIR', plugin_dir_path( __FILE__ ) );
66
67 // URL
68 define( 'CT_URL', plugin_dir_url( __FILE__ ) );
69
70 // Debug
71 define( 'CT_DEBUG', false );
72
73 }
74
75 /**
76 * Starts the version checking process.
77 * Creates CT_LOADED definition for early detection by other scripts.
78 *
79 * Hooks CT_Loader inclusion to the ct_loader_load hook
80 * on a high priority which decrements (increasing the priority) with
81 * each version release.
82 *
83 * @since 1.0.0
84 */
85 public function __construct() {
86
87 $priority = 99999 - absint( str_replace( '.', '', self::VERSION ) );
88
89 if ( ! defined( 'CT_LOADER_PRIORITY' ) ) {
90 // Calculate priority converting version into a number (eg: 1.0.0 to 100)
91 define( 'CT_LOADER_PRIORITY', $priority );
92 }
93
94
95 if ( ! defined( 'CT_LOADED' ) ) {
96 // A constant you can use to check if Custom Tables (CT) is loaded for your plugins/themes with CT dependency.
97 // Can also be used to determine the priority of the hook in use for the currently loaded version.
98 define( 'CT_LOADED', $priority );
99 }
100
101 // Use the hook system to ensure only the newest version is loaded.
102 add_action( 'ct_loader_load', array( $this, 'include_lib' ), $priority );
103
104 // Try to fire our hook as soon as possible,including right now (required for activation hooks).
105 self::fire_hook();
106
107 // Hook in to the first hook we have available and fire our `ct_loader_load' hook.
108 add_action( 'muplugins_loaded', array( __CLASS__, 'fire_hook' ), 9 );
109 add_action( 'plugins_loaded', array( __CLASS__, 'fire_hook' ), 9 );
110 add_action( 'after_setup_theme', array( __CLASS__, 'fire_hook' ), 9 );
111 }
112
113 /**
114 * Fires the ct_loader_load action hook.
115 *
116 * @since 1.0.0
117 */
118 public static function fire_hook() {
119 if ( ! did_action( 'ct_loader_load' ) ) {
120 // Then fire our hook.
121 do_action( 'ct_loader_load' );
122 }
123 }
124
125 /**
126 * A final check if CT_Loader exists before kicking off
127 * our CT_Loader loading.
128 *
129 * @since 1.0.0
130 */
131 public function include_lib() {
132 if ( class_exists( 'CT', false ) ) {
133 return;
134 }
135
136 $this->constants();
137
138 // Include and initiate Custom Tables (CT) class.
139 require_once CT_DIR . 'includes/class-ct.php';
140 }
141
142 }
143
144 // Kick it off.
145 new CT_Loader_111;
146 }
147