PluginProbe
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI / 6.0.3
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI v6.0.3
6.0.3 6.0.2 6.0.1 6.0.0 5.8.6 5.8.5 5.8.4 5.8.3 5.8.2 5.8.1 5.8.0 5.7.9.2 5.7.9.1 5.7.8 5.7.9 5.7.6 5.7.7 5.7.5 5.7.4 5.7.3 5.7.2 5.7.1 trunk 5.6.0 5.6.1 All 34 releases
← All changes | libraries/ct/includes/class-ct.php +206 -0 5.7.8 → 6.0.3 View file →
@@ -1,0 +1,206 @@
1 +<?php
2 +/**
3 + * Custom Tables main class
4 + *
5 + * @since 1.0.0
6 + *
7 + * @package Custom_Tables
8 + * @author GamiPress <[email protected]>, Ruben Garcia <[email protected]>
9 + * @copyright Copyright (c) GamiPress
10 + */
11 +// Exit if accessed directly
12 +defined( 'ABSPATH' ) || exit;
13 +
14 +/*
15 + * Copyright (c) GamiPress ([email protected]), AutomatorWP ([email protected]), Ruben Garcia ([email protected])
16 + *
17 + * This program is free software: you can redistribute it and/or modify it
18 + * under the terms of the GNU Affero General Public License, version 3,
19 + * as published by the Free Software Foundation.
20 + *
21 + * This program is distributed in the hope that it will be useful, but
22 + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23 + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
24 + * Public License for more details.
25 + *
26 + * You should have received a copy of the GNU Affero General Public License
27 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 + */
29 +
30 +if ( ! class_exists( 'CT' ) ) :
31 +
32 + final class CT {
33 +
34 + /**
35 + * @var CT $instance The one true CT
36 + * @since 1.0.0
37 + */
38 + private static $instance;
39 +
40 + /**
41 + * Get active instance
42 + *
43 + * @access public
44 + * @since 1.0.0
45 + * @return object self::$instance The one true CT
46 + */
47 + public static function instance() {
48 +
49 + if( ! self::$instance ) {
50 +
51 + self::$instance = new CT();
52 + self::$instance->includes();
53 + self::$instance->compatibility();
54 + self::$instance->hooks();
55 +
56 + }
57 +
58 + return self::$instance;
59 +
60 + }
61 +
62 + /**
63 + * Include CT files
64 + *
65 + * @access private
66 + * @since 1.0.0
67 + * @return void
68 + */
69 + private function includes() {
70 +
71 + // WP_List_Table dependencies
72 + if( ! function_exists( 'convert_to_screen' ) ) {
73 + require_once ABSPATH . 'wp-admin/includes/template.php';
74 + }
75 +
76 + if( ! function_exists( 'get_column_headers' ) ) {
77 + require_once ABSPATH . 'wp-admin/includes/screen.php';
78 + }
79 +
80 + // Includes required WP_List_Table class
81 + if( ! class_exists( 'WP_List_Table' ) ) {
82 + require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
83 + }
84 +
85 + // CT_Table and CT_Table_Meta classes
86 + require_once CT_DIR . 'includes/class-ct-table.php';
87 + require_once CT_DIR . 'includes/class-ct-table-meta.php';
88 + // Database and schema related classes
89 + require_once CT_DIR . 'includes/class-ct-database.php';
90 + require_once CT_DIR . 'includes/class-ct-database-schema.php';
91 + require_once CT_DIR . 'includes/class-ct-database-schema-updater.php';
92 + // Rest API
93 + require_once CT_DIR . 'includes/class-ct-rest-controller.php';
94 + require_once CT_DIR . 'includes/class-ct-rest-meta-fields.php';
95 + // CT_Query and CT_List_Table classes
96 + require_once CT_DIR . 'includes/class-ct-query.php';
97 + require_once CT_DIR . 'includes/class-ct-list-table.php';
98 + // Views (List and edit)
99 + require_once CT_DIR . 'includes/class-ct-view.php';
100 + require_once CT_DIR . 'includes/class-ct-list-view.php';
101 + require_once CT_DIR . 'includes/class-ct-edit-view.php';
102 + // Rest of includes
103 + require_once CT_DIR . 'includes/functions.php';
104 + require_once CT_DIR . 'includes/hooks.php';
105 + require_once CT_DIR . 'includes/scripts.php';
106 + require_once CT_DIR . 'includes/taxonomy.php';
107 +
108 + }
109 +
110 + /**
111 + * Include CT compatibility files
112 + *
113 + * @access private
114 + * @since 1.0.0
115 + * @return void
116 + */
117 + private function compatibility() {
118 +
119 + require_once CT_DIR . 'compatibility/cmb2.php';
120 +
121 + }
122 +
123 + /**
124 + * Setup CT hooks
125 + *
126 + * @access private
127 + * @since 1.0.0
128 + * @return void
129 + */
130 + private function hooks() {
131 +
132 + add_action( 'plugins_loaded', array( $this, 'init' ), 11 );
133 + add_action( 'after_setup_theme', array( $this, 'init' ), 11 );
134 + add_action( 'init', array( $this, 'load_textdomain' ), 10 );
135 +
136 + }
137 +
138 + public function init() {
139 +
140 + if ( did_action( 'ct_init' ) ) {
141 + return;
142 + }
143 +
144 + // Setup role caps for CT capabilities
145 + ct_populate_roles();
146 +
147 + // Trigger CT init hook
148 + do_action( 'ct_init' );
149 +
150 + if( is_admin() ) {
151 +
152 + // Trigger CT admin init hook
153 + do_action( 'ct_admin_init' );
154 +
155 + }
156 +
157 + }
158 +
159 + /**
160 + * Internationalization
161 + *
162 + * @access public
163 + * @since 1.0.0
164 + * @return void
165 + */
166 + public function load_textdomain() {
167 + // Set filter for language directory
168 + $lang_dir = CT_DIR . '/languages/';
169 + $lang_dir = apply_filters( 'ct_languages_directory', $lang_dir );
170 +
171 + // Traditional WordPress plugin locale filter
172 + $locale = apply_filters( 'plugin_locale', get_locale(), 'ct' );
173 + $mofile = sprintf( '%1$s-%2$s.mo', 'ct', $locale );
174 +
175 + // Setup paths to current locale file
176 + $mofile_local = $lang_dir . $mofile;
177 + $mofile_global = WP_LANG_DIR . '/ct/' . $mofile;
178 +
179 + if( file_exists( $mofile_global ) ) {
180 + // Look in global /wp-content/languages/ct/ folder
181 + load_textdomain( 'ct', $mofile_global );
182 + } elseif( file_exists( $mofile_local ) ) {
183 + // Look in local /wp-content/plugins/ct/languages/ folder
184 + load_textdomain( 'ct', $mofile_local );
185 + } else {
186 + // Load the default language files
187 + load_plugin_textdomain( 'ct', false, $lang_dir );
188 + }
189 + }
190 +
191 + }
192 +
193 +
194 + /**
195 + * The main function responsible for returning the one true CT instance to functions everywhere
196 + *
197 + * @since 1.0.0
198 + * @return \CT The one true CT
199 + */
200 + function ct() {
201 + return CT::instance();
202 + }
203 +
204 + ct();
205 +
206 +endif;