PluginProbe
Timetics – Appointment Booking Calendar & Scheduling / 1.0.7
Timetics – Appointment Booking Calendar & Scheduling v1.0.7
1.0.61 1.0.60 1.0.59 1.0.58 1.0.57 1.0.56 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 All 62 releases
timetics / timetics.php

timetics.php in Timetics – Appointment Booking Calendar & Scheduling 1.0.7, at timetics.php

280 lines 7.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Plugin Name: Timetics
5 * Plugin URI: https://arraytics.com/timetics/
6 * Description: Schedule, Appointment and Seat Booking plugin.
7 * Version: 1.0.7
8 * Requires at least: 5.2
9 * Requires PHP: 7.3
10 * Author: Arraytics
11 * Author URI: https://arraytics.com/
12 * License: GPL v2 or later
13 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
14 * Text Domain: timetics
15 * Domain Path: /languages
16
17 * Timetics is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation, either version 2 of the License, or
20 * any later version.
21
22 * Timetics Essential is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26
27 * You should have received a copy of the GNU General Public License
28 * along with Timetics. If not, see <http://www.gnu.org/licenses/>.
29 *
30 * @package Timetics
31 * @category Core
32 * @author Arraytics
33 * @version 1.0.7
34 */
35
36 // Exit if accessed directly.
37 defined( 'ABSPATH' ) || exit;
38
39 /**
40 * The Main Plugin Requirements Checker
41 *
42 * @since 1.0.0
43 */
44 final class Timetics {
45
46 /**
47 * Static Property To Hold Singleton Instance
48 *
49 * @var Timetics The Timetics Requirement Checker Instance
50 */
51 private static $instance;
52
53 /**
54 * Plugin Current Production Version
55 *
56 * @return string
57 */
58 public static function get_version() {
59 return '1.0.7';
60 }
61
62 /**
63 * Requirements Array
64 *
65 * @since 1.0.0
66 * @var array
67 */
68 private $requirements = array(
69 'php' => array(
70 'name' => 'PHP',
71 'minimum' => '7.3',
72 'exists' => true,
73 'met' => false,
74 'checked' => false,
75 'current' => false,
76 ),
77 'wp' => array(
78 'name' => 'WordPress',
79 'minimum' => '5.2',
80 'exists' => true,
81 'checked' => false,
82 'met' => false,
83 'current' => false,
84 ),
85 );
86
87 /**
88 * Singleton Instance
89 *
90 * @return Timetics
91 */
92 public static function get_instance() {
93 if ( null === self::$instance ) {
94 self::$instance = new self();
95 }
96
97 return self::$instance;
98 }
99
100 /**
101 * Setup Plugin Requirements
102 *
103 * @since 1.0.0
104 */
105 private function __construct() {
106 // Always load translation.
107 add_action( 'plugins_loaded', array( $this, 'load_text_domain' ) );
108
109 // Initialize plugin functionalities or quit.
110 $this->requirements_met() ? $this->initialize_modules() : $this->quit();
111 }
112
113 /**
114 * Load Localization Files
115 *
116 * @since 1.0
117 * @return void
118 */
119 public function load_text_domain() {
120 $locale = apply_filters( 'plugin_locale', get_user_locale(), 'timetics' );
121
122 unload_textdomain( 'timetics' );
123 load_textdomain( 'timetics', WP_LANG_DIR . '/timetics/timetics-' . $locale . '.mo' );
124 load_plugin_textdomain( 'timetics', false, self::get_plugin_dir() . 'languages/' );
125 }
126
127 /**
128 * Initialize Plugin Modules
129 *
130 * @since 1.0.0
131 * @return void
132 */
133 private function initialize_modules() {
134 require_once dirname( __FILE__ ) . '/autoloader.php';
135 require_once dirname( __FILE__ ) . '/core/settings/settings.php';
136
137 require_once dirname( __FILE__ ) . '/utils/global-helper.php';
138
139 // Include the bootstrap file if not loaded.
140 if ( ! class_exists( 'Timetics\Bootstrap' ) ) {
141 require_once self::get_plugin_dir() . 'bootstrap.php';
142 }
143
144 // Initialize the bootstraper if exists.
145 if ( class_exists( 'Timetics\Bootstrap' ) ) {
146
147 // Initialize all modules through plugins_loaded.
148 add_action( 'plugins_loaded', array( $this, 'init' ) );
149
150 register_activation_hook( self::get_plugin_file(), array( $this, 'activate' ) );
151 register_deactivation_hook( self::get_plugin_file(), array( $this, 'deactivate' ) );
152 }
153 }
154
155 /**
156 * Check If All Requirements Are Fulfilled
157 *
158 * @return boolean
159 */
160 private function requirements_met() {
161 $this->prepare_requirement_versions();
162
163 $passed = true;
164 $to_meet = wp_list_pluck( $this->requirements, 'met' );
165
166 foreach ( $to_meet as $met ) {
167 if ( empty( $met ) ) {
168 $passed = false;
169 continue;
170 }
171 }
172
173 return $passed;
174 }
175
176 /**
177 * Requirement Version Prepare
178 *
179 * @since 1.0.0
180 *
181 * @return void
182 */
183 private function prepare_requirement_versions() {
184 foreach ( $this->requirements as $dependency => $config ) {
185 switch ( $dependency ) {
186 case 'php':
187 $version = phpversion();
188 break;
189 case 'wp':
190 $version = get_bloginfo( 'version' );
191 break;
192 default:
193 $version = false;
194 }
195
196 if ( ! empty( $version ) ) {
197 $this->requirements[$dependency]['current'] = $version;
198 $this->requirements[$dependency]['checked'] = true;
199 $this->requirements[$dependency]['met'] = version_compare( $version, $config['minimum'], '>=' );
200 }
201 }
202 }
203
204 /**
205 * Initialize everything
206 *
207 * @since 1.0.0
208 *
209 * @return void
210 */
211 public function init() {
212 Timetics\Bootstrap::instantiate( self::get_plugin_file() );
213 }
214
215 /**
216 * Called Only Once While Activation
217 *
218 * @return void
219 */
220 public function activate() {
221 // Insert new role.
222 Timetics\Base\Role::instance()->init();
223
224 // Update default settings.
225 timetics_update_default_settings();
226
227 // Register cron
228 timetics_register_cron();
229
230 // Create new woocommerce product category for timetics meeting
231 timetics_add_woocommerce_product_cat();
232 }
233
234 /**
235 * Called Only Once While Deactivation
236 *
237 * @return void
238 */
239 public function deactivate() {
240 }
241
242 /**
243 * Quit Plugin Execution
244 *
245 * @return void
246 */
247 private function quit() {
248 add_action( 'admin_head', array( $this, 'show_plugin_requirements_not_met_notice' ) );
249 }
250
251 /**
252 * Show Error Notice For Missing Requirements
253 *
254 * @return void
255 */
256 public function show_plugin_requirements_not_met_notice() {
257 printf( '<div>Minimum requirements for Timetics are not met. Please update requirements to continue.</div>' );
258 }
259
260 /**
261 * Plugin Main File
262 *
263 * @return string
264 */
265 public static function get_plugin_file() {
266 return __FILE__;
267 }
268
269 /**
270 * Plugin Base Directory Path
271 *
272 * @return string
273 */
274 public static function get_plugin_dir() {
275 return trailingslashit( plugin_dir_path( self::get_plugin_file() ) );
276 }
277 }
278
279 Timetics::get_instance();
280