| @@ -1,11 +1,11 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | - * Plugin Name: Timetics | |
| 4 | + * Plugin Name: Timetics - Appointment Booking Calendar & Scheduling System | |
| 5 | 5 | * Plugin URI: https://arraytics.com/timetics/ |
| 6 | 6 | * Description: Schedule, Appointment and Seat Booking plugin. |
| 7 | - * Version: 1.0.15 | |
| 7 | + * Version: 1.0.64 | |
| 8 | 8 | * Requires at least: 5.2 |
| 9 | 9 | * Requires PHP: 7.3 |
| 10 | 10 | * Author: Arraytics |
| 11 | 11 | * Author URI: https://arraytics.com/ |
| @@ -55,9 +55,9 @@ | ||
| 55 | 55 | * |
| 56 | 56 | * @return string |
| 57 | 57 | */ |
| 58 | 58 | public static function get_version() { |
| 59 | - return '1.0.15'; | |
| 59 | + return '1.0.64'; | |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * Requirements Array |
| @@ -103,9 +103,9 @@ | ||
| 103 | 103 | * @since 1.0.0 |
| 104 | 104 | */ |
| 105 | 105 | private function __construct() { |
| 106 | 106 | // Always load translation. |
| 107 | - add_action( 'plugins_loaded', array( $this, 'load_text_domain' ) ); | |
| 107 | + add_action( 'init', array( $this, 'load_text_domain' ) ); | |
| 108 | 108 | |
| 109 | 109 | // Initialize plugin functionalities or quit. |
| 110 | 110 | $this->requirements_met() ? $this->initialize_modules() : $this->quit(); |
| 111 | 111 | } |
| @@ -116,13 +116,31 @@ | ||
| 116 | 116 | * @since 1.0 |
| 117 | 117 | * @return void |
| 118 | 118 | */ |
| 119 | 119 | public function load_text_domain() { |
| 120 | - $locale = apply_filters( 'plugin_locale', get_user_locale(), 'timetics' ); | |
| 120 | + $locale = determine_locale(); | |
| 121 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- WordPress core localization hook. | |
| 122 | + $locale = apply_filters( 'plugin_locale', $locale, 'timetics' ); | |
| 123 | + $locale = apply_filters( 'timetics_plugin_locale', $locale, 'timetics' ); | |
| 121 | 124 | |
| 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 | + $mofile = 'timetics-' . $locale . '.mo'; | |
| 126 | + | |
| 127 | + // Loco "Custom" location. | |
| 128 | + if ( file_exists( WP_LANG_DIR . '/loco/plugins/' . $mofile ) ) { | |
| 129 | + load_textdomain( 'timetics', WP_LANG_DIR . '/loco/plugins/' . $mofile ); | |
| 130 | + } | |
| 131 | + | |
| 132 | + // Loco "System" location. | |
| 133 | + if ( file_exists( WP_LANG_DIR . '/plugins/' . $mofile ) ) { | |
| 134 | + load_textdomain( 'timetics', WP_LANG_DIR . '/plugins/' . $mofile ); | |
| 135 | + } | |
| 136 | + | |
| 137 | + // Bundled translations remain available while WordPress loads language | |
| 138 | + // packs for this text domain automatically. | |
| 139 | + $bundled_mofile = plugin_dir_path( __FILE__ ) . 'languages/' . $mofile; | |
| 140 | + if ( file_exists( $bundled_mofile ) ) { | |
| 141 | + load_textdomain( 'timetics', $bundled_mofile ); | |
| 142 | + } | |
| 125 | 143 | } |
| 126 | 144 | |
| 127 | 145 | /** |
| 128 | 146 | * Initialize Plugin Modules |
| @@ -138,9 +156,8 @@ | ||
| 138 | 156 | |
| 139 | 157 | // block for showing banner. |
| 140 | 158 | require_once plugin_dir_path( __FILE__ ) . '/utils/notice/notice.php'; |
| 141 | 159 | require_once plugin_dir_path( __FILE__ ) . '/utils/banner/banner.php'; |
| 142 | - require_once plugin_dir_path( __FILE__ ) . '/utils/pro-awareness/pro-awareness.php'; | |
| 143 | 160 | |
| 144 | 161 | // Include the bootstrap file if not loaded. |
| 145 | 162 | if ( ! class_exists( 'Timetics\Bootstrap' ) ) { |
| 146 | 163 | require_once self::get_plugin_dir() . 'bootstrap.php'; |
| @@ -148,11 +165,8 @@ | ||
| 148 | 165 | |
| 149 | 166 | // init notice class. |
| 150 | 167 | \Oxaim\Libs\Notice::init(); |
| 151 | 168 | |
| 152 | - // init pro menu class. | |
| 153 | - \Wpmet\Libs\Pro_Awareness::init(); | |
| 154 | - | |
| 155 | 169 | // Initialize the bootstraper if exists. |
| 156 | 170 | if ( class_exists( 'Timetics\Bootstrap' ) ) { |
| 157 | 171 | |
| 158 | 172 | // Initialize all modules through plugins_loaded. |
| @@ -220,8 +234,64 @@ | ||
| 220 | 234 | * @return void |
| 221 | 235 | */ |
| 222 | 236 | public function init() { |
| 223 | 237 | Timetics\Bootstrap::instantiate( self::get_plugin_file() ); |
| 238 | + | |
| 239 | + // Add autoload from composer for integrating uninstallation form | |
| 240 | + if (file_exists(plugin_dir_path( __FILE__ ) . '/vendor/autoload.php')) { | |
| 241 | + require_once plugin_dir_path( __FILE__ ) . '/vendor/autoload.php'; | |
| 242 | + } | |
| 243 | + | |
| 244 | + if (class_exists('UninstallerForm\UninstallerForm') && is_callable(['\UninstallerForm\UninstallerForm', 'init'])) { | |
| 245 | + | |
| 246 | + $reflection = new ReflectionMethod('\UninstallerForm\UninstallerForm', 'init'); | |
| 247 | + | |
| 248 | + // Maximum number of parameters allowed | |
| 249 | + $totalParams = $reflection->getNumberOfParameters(); | |
| 250 | + | |
| 251 | + if($totalParams === 6) { | |
| 252 | + add_filter( 'rest_request_before_callbacks', function( $response, $handler, $request ) { | |
| 253 | + if ( $request->get_route() === '/timetics/v1/feedback' ) { | |
| 254 | + $params = $request->get_json_params(); | |
| 255 | + | |
| 256 | + if ( empty( $params['email'] ) ) { | |
| 257 | + $params['email'] = get_option( 'admin_email' ); | |
| 258 | + $request->set_body( wp_json_encode( $params ) ); | |
| 259 | + } | |
| 260 | + } | |
| 261 | + return $response; | |
| 262 | + }, 10, 3 ); | |
| 263 | + | |
| 264 | + \UninstallerForm\UninstallerForm::init( | |
| 265 | + 'Timetics', // Plugin name | |
| 266 | + 'timetics', // Plugin Slug | |
| 267 | + __FILE__, | |
| 268 | + 'timetics', // Text Domain Name | |
| 269 | + 'timetics-feedback-modal', // plugins-admin-script-handler | |
| 270 | + 'https://arraytics.com/?fluentcrm=1&route=contact&hash=13cce8a6-c038-4997-91e7-4a2326cc1124' | |
| 271 | + ); | |
| 272 | + } else { | |
| 273 | + add_filter( 'rest_request_before_callbacks', function( $response, $handler, $request ) { | |
| 274 | + if ( $request->get_route() === '/timetics/v1/feedback' ) { | |
| 275 | + $params = $request->get_json_params(); | |
| 276 | + | |
| 277 | + if ( empty( $params['email'] ) ) { | |
| 278 | + $params['email'] = get_option( 'admin_email' ); | |
| 279 | + $request->set_body( wp_json_encode( $params ) ); | |
| 280 | + } | |
| 281 | + } | |
| 282 | + return $response; | |
| 283 | + }, 10, 3 ); | |
| 284 | + | |
| 285 | + \UninstallerForm\UninstallerForm::init( | |
| 286 | + 'Timetics', // Plugin name | |
| 287 | + 'timetics', // Plugin Slug | |
| 288 | + __FILE__, | |
| 289 | + 'timetics', // Text Domain Name | |
| 290 | + 'timetics-feedback-modal' | |
| 291 | + ); | |
| 292 | + } | |
| 293 | + } | |
| 224 | 294 | } |
| 225 | 295 | |
| 226 | 296 | /** |
| 227 | 297 | * Called Only Once While Activation |
| @@ -240,11 +310,22 @@ | ||
| 240 | 310 | |
| 241 | 311 | // Create new woocommerce product category for timetics meeting |
| 242 | 312 | timetics_add_woocommerce_product_cat(); |
| 243 | 313 | |
| 314 | + // Force rewrite-rule flush on activation; the maybe_flush_rules guard handles subsequent upgrades. | |
| 315 | + delete_option( 'timetics_rewrite_version' ); | |
| 316 | + | |
| 244 | 317 | // Update option for onboard settings. |
| 245 | 318 | $timetics_onboard_setup = get_option( 'timetics_onboard_setup' ); |
| 246 | 319 | |
| 320 | + $timetics_demo_data = get_option( 'timetics_demo_data' ); | |
| 321 | + | |
| 322 | + if ( ! $timetics_demo_data ) { | |
| 323 | + $dummy_data_generator = new Timetics\Core\DummyData\Dummy_Data_Generator(); | |
| 324 | + $dummy_data_generator->generate(); | |
| 325 | + update_option( 'timetics_demo_data', true ); | |
| 326 | + } | |
| 327 | + | |
| 247 | 328 | if ( ! $timetics_onboard_setup ) { |
| 248 | 329 | update_option( 'timetics_onboard_settings', true ); |
| 249 | 330 | } |
| 250 | 331 | } |
| @@ -254,8 +335,9 @@ | ||
| 254 | 335 | * |
| 255 | 336 | * @return void |
| 256 | 337 | */ |
| 257 | 338 | public function deactivate() { |
| 339 | + wp_clear_scheduled_hook( 'timetics_cleanup_unpaid_bookings' ); | |
| 258 | 340 | } |
| 259 | 341 | |
| 260 | 342 | /** |
| 261 | 343 | * Quit Plugin Execution |
| @@ -292,6 +374,34 @@ | ||
| 292 | 374 | public static function get_plugin_dir() { |
| 293 | 375 | return trailingslashit( plugin_dir_path( self::get_plugin_file() ) ); |
| 294 | 376 | } |
| 295 | 377 | } |
| 378 | + | |
| 379 | +/** | |
| 380 | + * Add a "Go Pro" action link on the Plugins page. | |
| 381 | + * Hidden when the pro plugin already exists. | |
| 382 | + */ | |
| 383 | +if ( ! function_exists( 'timetics_add_go_pro_action_link' ) ) { | |
| 384 | + function timetics_add_go_pro_action_link( $links ) { | |
| 385 | + if ( ! function_exists( 'get_plugins' ) ) { | |
| 386 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; | |
| 387 | + } | |
| 388 | + | |
| 389 | + foreach ( get_plugins() as $plugin ) { | |
| 390 | + if ( isset( $plugin['TextDomain'] ) && 'timetics-pro' === $plugin['TextDomain'] ) { | |
| 391 | + return $links; | |
| 392 | + } | |
| 393 | + } | |
| 394 | + | |
| 395 | + $go_pro = sprintf( | |
| 396 | + '<a href="%1$s" target="_blank" rel="noopener noreferrer" style="color:#e8364c;font-weight:600;">%2$s</a>', | |
| 397 | + esc_url( 'https://arraytics.com/timetics/pricing/' ), | |
| 398 | + esc_html__( 'Go Pro', 'timetics' ) | |
| 399 | + ); | |
| 400 | + | |
| 401 | + $links[] = $go_pro; | |
| 402 | + return $links; | |
| 403 | + } | |
| 404 | +} | |
| 405 | +add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'timetics_add_go_pro_action_link' ); | |
| 296 | 406 | |
| 297 | 407 | Timetics::get_instance(); |