| @@ -3,9 +3,9 @@ | ||
| 3 | 3 | /** |
| 4 | 4 | * Plugin Name: Timetics |
| 5 | 5 | * Plugin URI: https://arraytics.com/timetics/ |
| 6 | 6 | * Description: Schedule, Appointment and Seat Booking plugin. |
| 7 | - * Version: 1.0.0 | |
| 7 | + * Version: 1.0.38 | |
| 8 | 8 | * Requires at least: 5.2 |
| 9 | 9 | * Requires PHP: 7.3 |
| 10 | 10 | * Author: Arraytics |
| 11 | 11 | * Author URI: https://arraytics.com/ |
| @@ -29,13 +29,13 @@ | ||
| 29 | 29 | * |
| 30 | 30 | * @package Timetics |
| 31 | 31 | * @category Core |
| 32 | 32 | * @author Arraytics |
| 33 | - * @version 1.0.0 | |
| 33 | + * @version 1.0.10 | |
| 34 | 34 | */ |
| 35 | 35 | |
| 36 | 36 | // Exit if accessed directly. |
| 37 | -defined('ABSPATH') || exit; | |
| 37 | +defined( 'ABSPATH' ) || exit; | |
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * The Main Plugin Requirements Checker |
| 41 | 41 | * |
| @@ -40,249 +40,283 @@ | ||
| 40 | 40 | * The Main Plugin Requirements Checker |
| 41 | 41 | * |
| 42 | 42 | * @since 1.0.0 |
| 43 | 43 | */ |
| 44 | -final class Timetics | |
| 45 | -{ | |
| 44 | +final class Timetics { | |
| 46 | 45 | |
| 47 | - /** | |
| 48 | - * Static Property To Hold Singleton Instance | |
| 49 | - * | |
| 50 | - * @var Timetics The Timetics Requirement Checker Instance | |
| 51 | - */ | |
| 52 | - private static $instance; | |
| 46 | + /** | |
| 47 | + * Static Property To Hold Singleton Instance | |
| 48 | + * | |
| 49 | + * @var Timetics The Timetics Requirement Checker Instance | |
| 50 | + */ | |
| 51 | + private static $instance; | |
| 53 | 52 | |
| 54 | - /** | |
| 55 | - * Requirements Array | |
| 56 | - * | |
| 57 | - * @since 1.0.0 | |
| 58 | - * @var array | |
| 59 | - */ | |
| 60 | - private $requirements = array( | |
| 61 | - 'php' => array( | |
| 62 | - 'name' => 'PHP', | |
| 63 | - 'minimum' => '7.3', | |
| 64 | - 'exists' => true, | |
| 65 | - 'met' => false, | |
| 66 | - 'checked' => false, | |
| 67 | - 'current' => false, | |
| 68 | - ), | |
| 69 | - 'wp' => array( | |
| 70 | - 'name' => 'WordPress', | |
| 71 | - 'minimum' => '5.2', | |
| 72 | - 'exists' => true, | |
| 73 | - 'checked' => false, | |
| 74 | - 'met' => false, | |
| 75 | - 'current' => false, | |
| 76 | - ), | |
| 77 | - ); | |
| 53 | + /** | |
| 54 | + * Plugin Current Production Version | |
| 55 | + * | |
| 56 | + * @return string | |
| 57 | + */ | |
| 58 | + public static function get_version() { | |
| 59 | + return '1.0.38'; | |
| 60 | + } | |
| 78 | 61 | |
| 79 | - /** | |
| 80 | - * Singleton Instance | |
| 81 | - * | |
| 82 | - * @return Timetics | |
| 83 | - */ | |
| 84 | - public static function get_instance() | |
| 85 | - { | |
| 86 | - if (null === self::$instance) { | |
| 87 | - self::$instance = new self(); | |
| 88 | - } | |
| 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 | + ); | |
| 89 | 86 | |
| 90 | - return self::$instance; | |
| 91 | - } | |
| 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 | + } | |
| 92 | 96 | |
| 93 | - /** | |
| 94 | - * Setup Plugin Requirements | |
| 95 | - * | |
| 96 | - * @since 1.0.0 | |
| 97 | - */ | |
| 98 | - private function __construct() | |
| 99 | - { | |
| 100 | - // Always load translation. | |
| 101 | - add_action('plugins_loaded', array($this, 'load_text_domain')); | |
| 97 | + return self::$instance; | |
| 98 | + } | |
| 102 | 99 | |
| 103 | - // Initialize plugin functionalities or quit. | |
| 104 | - $this->requirements_met() ? $this->initialize_modules() : $this->quit(); | |
| 105 | - } | |
| 100 | + /** | |
| 101 | + * Setup Plugin Requirements | |
| 102 | + * | |
| 103 | + * @since 1.0.0 | |
| 104 | + */ | |
| 105 | + private function __construct() { | |
| 106 | + // Always load translation. | |
| 107 | + add_action( 'init', array( $this, 'load_text_domain' ) ); | |
| 106 | 108 | |
| 107 | - /** | |
| 108 | - * Load Localization Files | |
| 109 | - * | |
| 110 | - * @since 1.0 | |
| 111 | - * @return void | |
| 112 | - */ | |
| 113 | - public function load_text_domain() | |
| 114 | - { | |
| 115 | - $locale = apply_filters('plugin_locale', get_user_locale(), 'timetics'); | |
| 109 | + // Initialize plugin functionalities or quit. | |
| 110 | + $this->requirements_met() ? $this->initialize_modules() : $this->quit(); | |
| 111 | + } | |
| 116 | 112 | |
| 117 | - unload_textdomain('timetics'); | |
| 118 | - load_textdomain('timetics', WP_LANG_DIR . '/timetics/timetics-' . $locale . '.mo'); | |
| 119 | - load_plugin_textdomain('timetics', false, self::get_plugin_dir() . 'languages/'); | |
| 120 | - } | |
| 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 | 121 | |
| 122 | - /** | |
| 123 | - * Initialize Plugin Modules | |
| 124 | - * | |
| 125 | - * @since 1.0.0 | |
| 126 | - * @return void | |
| 127 | - */ | |
| 128 | - private function initialize_modules() | |
| 129 | - { | |
| 130 | - require_once dirname(__FILE__) . '/autoloader.php'; | |
| 131 | - require_once dirname(__FILE__) . '/core/settings/settings.php'; | |
| 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 | + } | |
| 132 | 126 | |
| 133 | - require_once dirname(__FILE__) . '/utils/global-helper.php'; | |
| 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'; | |
| 134 | 136 | |
| 135 | - // Include the bootstrap file if not loaded. | |
| 136 | - if (!class_exists('Timetics\Bootstrap')) { | |
| 137 | - require_once self::get_plugin_dir() . 'bootstrap.php'; | |
| 138 | - } | |
| 137 | + require_once dirname( __FILE__ ) . '/utils/global-helper.php'; | |
| 139 | 138 | |
| 140 | - // Initialize the bootstraper if exists. | |
| 141 | - if (class_exists('Timetics\Bootstrap')) { | |
| 139 | + // block for showing banner. | |
| 140 | + require_once plugin_dir_path( __FILE__ ) . '/utils/notice/notice.php'; | |
| 141 | + require_once plugin_dir_path( __FILE__ ) . '/utils/banner/banner.php'; | |
| 142 | + require_once plugin_dir_path( __FILE__ ) . '/utils/pro-awareness/pro-awareness.php'; | |
| 142 | 143 | |
| 143 | - // Initialize all modules through plugins_loaded. | |
| 144 | - add_action('plugins_loaded', array($this, 'init')); | |
| 144 | + // Include the bootstrap file if not loaded. | |
| 145 | + if ( ! class_exists( 'Timetics\Bootstrap' ) ) { | |
| 146 | + require_once self::get_plugin_dir() . 'bootstrap.php'; | |
| 147 | + } | |
| 145 | 148 | |
| 146 | - register_activation_hook(self::get_plugin_file(), array($this, 'activate')); | |
| 147 | - register_deactivation_hook(self::get_plugin_file(), array($this, 'deactivate')); | |
| 148 | - } | |
| 149 | - } | |
| 149 | + // init notice class. | |
| 150 | + \Oxaim\Libs\Notice::init(); | |
| 150 | 151 | |
| 151 | - /** | |
| 152 | - * Check If All Requirements Are Fulfilled | |
| 153 | - * | |
| 154 | - * @return boolean | |
| 155 | - */ | |
| 156 | - private function requirements_met() | |
| 157 | - { | |
| 158 | - $this->prepare_requirement_versions(); | |
| 152 | + // init pro menu class. | |
| 153 | + \Wpmet\Libs\Pro_Awareness::init(); | |
| 159 | 154 | |
| 160 | - $passed = true; | |
| 161 | - $to_meet = wp_list_pluck($this->requirements, 'met'); | |
| 155 | + // Initialize the bootstraper if exists. | |
| 156 | + if ( class_exists( 'Timetics\Bootstrap' ) ) { | |
| 162 | 157 | |
| 163 | - foreach ($to_meet as $met) { | |
| 164 | - if (empty($met)) { | |
| 165 | - $passed = false; | |
| 166 | - continue; | |
| 167 | - } | |
| 168 | - } | |
| 158 | + // Initialize all modules through plugins_loaded. | |
| 159 | + add_action( 'plugins_loaded', array( $this, 'init' ) ); | |
| 169 | 160 | |
| 170 | - return $passed; | |
| 171 | - } | |
| 161 | + register_activation_hook( self::get_plugin_file(), array( $this, 'activate' ) ); | |
| 162 | + register_deactivation_hook( self::get_plugin_file(), array( $this, 'deactivate' ) ); | |
| 163 | + } | |
| 164 | + } | |
| 172 | 165 | |
| 173 | - /** | |
| 174 | - * Requirement Version Prepare | |
| 175 | - * | |
| 176 | - * @since 1.0.0 | |
| 177 | - * | |
| 178 | - * @return void | |
| 179 | - */ | |
| 180 | - private function prepare_requirement_versions() | |
| 181 | - { | |
| 182 | - foreach ($this->requirements as $dependency => $config) { | |
| 183 | - switch ($dependency) { | |
| 184 | - case 'php': | |
| 185 | - $version = phpversion(); | |
| 186 | - break; | |
| 187 | - case 'wp': | |
| 188 | - $version = get_bloginfo('version'); | |
| 189 | - break; | |
| 190 | - default: | |
| 191 | - $version = false; | |
| 192 | - } | |
| 166 | + /** | |
| 167 | + * Check If All Requirements Are Fulfilled | |
| 168 | + * | |
| 169 | + * @return boolean | |
| 170 | + */ | |
| 171 | + private function requirements_met() { | |
| 172 | + $this->prepare_requirement_versions(); | |
| 193 | 173 | |
| 194 | - if (!empty($version)) { | |
| 195 | - $this->requirements[$dependency]['current'] = $version; | |
| 196 | - $this->requirements[$dependency]['checked'] = true; | |
| 197 | - $this->requirements[$dependency]['met'] = version_compare($version, $config['minimum'], '>='); | |
| 198 | - } | |
| 199 | - } | |
| 200 | - } | |
| 174 | + $passed = true; | |
| 175 | + $to_meet = wp_list_pluck( $this->requirements, 'met' ); | |
| 201 | 176 | |
| 202 | - /** | |
| 203 | - * Initialize everything | |
| 204 | - * | |
| 205 | - * @since 1.0.0 | |
| 206 | - * | |
| 207 | - * @return void | |
| 208 | - */ | |
| 209 | - public function init() | |
| 210 | - { | |
| 211 | - Timetics\Bootstrap::instantiate(self::get_plugin_file()); | |
| 212 | - } | |
| 177 | + foreach ( $to_meet as $met ) { | |
| 178 | + if ( empty( $met ) ) { | |
| 179 | + $passed = false; | |
| 180 | + continue; | |
| 181 | + } | |
| 182 | + } | |
| 213 | 183 | |
| 214 | - /** | |
| 215 | - * Called Only Once While Activation | |
| 216 | - * | |
| 217 | - * @return void | |
| 218 | - */ | |
| 219 | - public function activate() | |
| 220 | - { | |
| 221 | - // Insert new role. | |
| 222 | - Timetics\Base\Role::instance()->init(); | |
| 184 | + return $passed; | |
| 185 | + } | |
| 223 | 186 | |
| 224 | - // Update default settings. | |
| 225 | - timetics_update_default_settings(); | |
| 226 | - } | |
| 187 | + /** | |
| 188 | + * Requirement Version Prepare | |
| 189 | + * | |
| 190 | + * @since 1.0.0 | |
| 191 | + * | |
| 192 | + * @return void | |
| 193 | + */ | |
| 194 | + private function prepare_requirement_versions() { | |
| 195 | + foreach ( $this->requirements as $dependency => $config ) { | |
| 196 | + switch ( $dependency ) { | |
| 197 | + case 'php': | |
| 198 | + $version = phpversion(); | |
| 199 | + break; | |
| 200 | + case 'wp': | |
| 201 | + $version = get_bloginfo( 'version' ); | |
| 202 | + break; | |
| 203 | + default: | |
| 204 | + $version = false; | |
| 205 | + } | |
| 227 | 206 | |
| 228 | - /** | |
| 229 | - * Called Only Once While Deactivation | |
| 230 | - * | |
| 231 | - * @return void | |
| 232 | - */ | |
| 233 | - public function deactivate() | |
| 234 | - { | |
| 235 | - } | |
| 207 | + if ( ! empty( $version ) ) { | |
| 208 | + $this->requirements[$dependency]['current'] = $version; | |
| 209 | + $this->requirements[$dependency]['checked'] = true; | |
| 210 | + $this->requirements[$dependency]['met'] = version_compare( $version, $config['minimum'], '>=' ); | |
| 211 | + } | |
| 212 | + } | |
| 213 | + } | |
| 236 | 214 | |
| 237 | - /** | |
| 238 | - * Quit Plugin Execution | |
| 239 | - * | |
| 240 | - * @return void | |
| 241 | - */ | |
| 242 | - private function quit() | |
| 243 | - { | |
| 244 | - add_action('admin_head', array($this, 'show_plugin_requirements_not_met_notice')); | |
| 245 | - } | |
| 215 | + /** | |
| 216 | + * Initialize everything | |
| 217 | + * | |
| 218 | + * @since 1.0.0 | |
| 219 | + * | |
| 220 | + * @return void | |
| 221 | + */ | |
| 222 | + public function init() { | |
| 223 | + Timetics\Bootstrap::instantiate( self::get_plugin_file() ); | |
| 246 | 224 | |
| 247 | - /** | |
| 248 | - * Show Error Notice For Missing Requirements | |
| 249 | - * | |
| 250 | - * @return void | |
| 251 | - */ | |
| 252 | - public function show_plugin_requirements_not_met_notice() | |
| 253 | - { | |
| 254 | - printf('<div>Minimum requirements for Timetics are not met. Please update requirements to continue.</div>'); | |
| 255 | - } | |
| 225 | + // Add autoload from composer for integrating uninstallation form | |
| 226 | + if (file_exists(plugin_dir_path( __FILE__ ) . '/vendor/autoload.php')) { | |
| 227 | + require_once plugin_dir_path( __FILE__ ) . '/vendor/autoload.php'; | |
| 228 | + } | |
| 256 | 229 | |
| 257 | - /** | |
| 258 | - * Plugin Current Production Version | |
| 259 | - * | |
| 260 | - * @return string | |
| 261 | - */ | |
| 262 | - public static function get_version() | |
| 263 | - { | |
| 264 | - return '1.0.0'; | |
| 265 | - } | |
| 230 | + if ( class_exists( 'UninstallerForm\UninstallerForm' ) ) { | |
| 231 | + $uninstaller_form = new \UninstallerForm\UninstallerForm(); | |
| 232 | + $uninstaller_form->init( | |
| 233 | + 'Timetics', // Plugin name | |
| 234 | + 'timetics', // Plugin Slug | |
| 235 | + __FILE__, | |
| 236 | + 'timetics', // Text Domain Name | |
| 237 | + 'timetics-feedback-modal', // plugins-admin-script-handler | |
| 238 | + 'https://arraytics.com/?fluentcrm=1&route=contact&hash=13cce8a6-c038-4997-91e7-4a2326cc1124' | |
| 239 | + ); | |
| 240 | + } | |
| 241 | + } | |
| 266 | 242 | |
| 267 | - /** | |
| 268 | - * Plugin Main File | |
| 269 | - * | |
| 270 | - * @return string | |
| 271 | - */ | |
| 272 | - public static function get_plugin_file() | |
| 273 | - { | |
| 274 | - return __FILE__; | |
| 275 | - } | |
| 243 | + /** | |
| 244 | + * Called Only Once While Activation | |
| 245 | + * | |
| 246 | + * @return void | |
| 247 | + */ | |
| 248 | + public function activate() { | |
| 249 | + // Insert new role. | |
| 250 | + Timetics\Base\Role::instance()->init(); | |
| 276 | 251 | |
| 277 | - /** | |
| 278 | - * Plugin Base Directory Path | |
| 279 | - * | |
| 280 | - * @return string | |
| 281 | - */ | |
| 282 | - public static function get_plugin_dir() | |
| 283 | - { | |
| 284 | - return trailingslashit(plugin_dir_path(self::get_plugin_file())); | |
| 285 | - } | |
| 252 | + // Update default settings. | |
| 253 | + timetics_update_default_settings(); | |
| 254 | + | |
| 255 | + // Register cron | |
| 256 | + timetics_register_cron(); | |
| 257 | + | |
| 258 | + // Create new woocommerce product category for timetics meeting | |
| 259 | + timetics_add_woocommerce_product_cat(); | |
| 260 | + | |
| 261 | + // Update option for onboard settings. | |
| 262 | + $timetics_onboard_setup = get_option( 'timetics_onboard_setup' ); | |
| 263 | + | |
| 264 | + $timetics_demo_data = get_option( 'timetics_demo_data' ); | |
| 265 | + | |
| 266 | + if ( ! $timetics_demo_data ) { | |
| 267 | + $dummy_data_generator = new Timetics\Core\DummyData\Dummy_Data_Generator(); | |
| 268 | + $dummy_data_generator->generate(); | |
| 269 | + update_option( 'timetics_demo_data', true ); | |
| 270 | + } | |
| 271 | + | |
| 272 | + if ( ! $timetics_onboard_setup ) { | |
| 273 | + update_option( 'timetics_onboard_settings', true ); | |
| 274 | + } | |
| 275 | + } | |
| 276 | + | |
| 277 | + /** | |
| 278 | + * Called Only Once While Deactivation | |
| 279 | + * | |
| 280 | + * @return void | |
| 281 | + */ | |
| 282 | + public function deactivate() { | |
| 283 | + } | |
| 284 | + | |
| 285 | + /** | |
| 286 | + * Quit Plugin Execution | |
| 287 | + * | |
| 288 | + * @return void | |
| 289 | + */ | |
| 290 | + private function quit() { | |
| 291 | + add_action( 'admin_head', array( $this, 'show_plugin_requirements_not_met_notice' ) ); | |
| 292 | + } | |
| 293 | + | |
| 294 | + /** | |
| 295 | + * Show Error Notice For Missing Requirements | |
| 296 | + * | |
| 297 | + * @return void | |
| 298 | + */ | |
| 299 | + public function show_plugin_requirements_not_met_notice() { | |
| 300 | + printf( '<div>Minimum requirements for Timetics are not met. Please update requirements to continue.</div>' ); | |
| 301 | + } | |
| 302 | + | |
| 303 | + /** | |
| 304 | + * Plugin Main File | |
| 305 | + * | |
| 306 | + * @return string | |
| 307 | + */ | |
| 308 | + public static function get_plugin_file() { | |
| 309 | + return __FILE__; | |
| 310 | + } | |
| 311 | + | |
| 312 | + /** | |
| 313 | + * Plugin Base Directory Path | |
| 314 | + * | |
| 315 | + * @return string | |
| 316 | + */ | |
| 317 | + public static function get_plugin_dir() { | |
| 318 | + return trailingslashit( plugin_dir_path( self::get_plugin_file() ) ); | |
| 319 | + } | |
| 286 | 320 | } |
| 287 | 321 | |
| 288 | 322 | Timetics::get_instance(); |