PluginProbe ʕ •ᴥ•ʔ
TaxCloud for WooCommerce / 8.4.11
TaxCloud for WooCommerce v8.4.11
8.4.11 8.4.10 8.4.9 trunk 6.0.11 6.0.12 6.0.13 6.0.14 6.1.0 6.1.1 6.1.2 6.2.0 6.2.1 6.2.2 6.2.3 6.2.4 6.2.5 6.2.6 6.3.0 6.3.1 6.3.10 6.3.11 6.3.12 6.3.13 6.3.2 6.3.3 6.3.4 6.3.5 6.3.6 6.3.7 6.3.8 6.3.9 7.0.0 7.0.1 7.0.10 7.0.11 7.0.12 7.0.13 7.0.2 7.0.3 7.0.4 7.0.5 7.0.6 7.0.7 7.0.8 7.0.9 8.0.0 8.0.1 8.0.10 8.0.11 8.0.12 8.0.13 8.0.14 8.0.15 8.0.16 8.0.17 8.0.2 8.0.3 8.0.4 8.0.5 8.0.6 8.0.7 8.0.8 8.0.9 8.1.0 8.1.1 8.2.0 8.2.1 8.2.2 8.2.3 8.2.4 8.3.0 8.3.1 8.3.2 8.3.3 8.3.4 8.3.5 8.3.6 8.3.7 8.3.8 8.4.0 8.4.1 8.4.2 8.4.3 8.4.4 8.4.5 8.4.6 8.4.7 8.4.8
simple-sales-tax / includes / class-sst-updater.php
simple-sales-tax / includes Last commit date
abstracts 3 months ago admin 3 months ago frontend 1 month ago integrations 1 month ago v3 3 months ago vendor 6 days ago views 8 months ago class-simplesalestax.php 6 days ago class-sst-addresses.php 1 month ago class-sst-ajax.php 3 months ago class-sst-assets.php 6 months ago class-sst-blocks-integration.php 1 month ago class-sst-blocks.php 1 year ago class-sst-certificates.php 6 days ago class-sst-install.php 6 months ago class-sst-logger.php 5 months ago class-sst-marketplaces.php 6 months ago class-sst-order-controller.php 3 months ago class-sst-order.php 1 month ago class-sst-origin-address.php 8 months ago class-sst-product.php 3 months ago class-sst-rate-limit.php 5 months ago class-sst-settings.php 3 months ago class-sst-shipping.php 3 years ago class-sst-taxcloud-v3-api.php 3 months ago class-sst-taxcloud-v3.php 3 months ago class-sst-tic.php 2 years ago class-sst-updater.php 3 years ago sst-compatibility-functions.php 4 months ago sst-functions.php 6 days ago sst-message-functions.php 3 years ago sst-update-functions.php 11 months ago
class-sst-updater.php
148 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit; // Exit if accessed directly.
5 }
6
7 if ( ! class_exists( 'WP_Async_Request', false ) ) {
8 require_once WC()->plugin_path() . '/includes/libraries/wp-async-request.php';
9 }
10
11 if ( ! class_exists( 'WP_Background_Process', false ) ) {
12 require_once WC()->plugin_path() . '/includes/libraries/wp-background-process.php';
13 }
14
15 /**
16 * SST Updater.
17 *
18 * Uses https://github.com/A5hleyRich/wp-background-processing to handle DB
19 * updates in the background. Ripped from WooCommerce core.
20 *
21 * @author Simple Sales Tax
22 * @package SST
23 * @since 5.0
24 */
25 class SST_Updater extends WP_Background_Process {
26
27 /**
28 * Action for background process.
29 *
30 * @var string
31 */
32 protected $action = 'sst_updater';
33
34 /**
35 * Dispatch updater.
36 *
37 * Updater will still run via cron job if this fails for any reason.
38 */
39 public function dispatch() {
40 $dispatched = parent::dispatch();
41 $logger = new WC_Logger();
42
43 if ( is_wp_error( $dispatched ) ) {
44 $logger->add(
45 'sst_db_updates',
46 sprintf( 'Unable to dispatch Simple Sales Tax updater: %s', $dispatched->get_error_message() )
47 );
48 }
49 }
50
51 /**
52 * Handle cron healthcheck
53 *
54 * Restart the background process if not already running
55 * and data exists in the queue.
56 */
57 public function handle_cron_healthcheck() {
58 if ( $this->is_process_running() ) {
59 // Background process already running.
60 return;
61 }
62
63 if ( $this->is_queue_empty() ) {
64 // No data to process.
65 $this->clear_scheduled_event();
66
67 return;
68 }
69
70 $this->handle();
71 }
72
73 /**
74 * Schedule fallback event.
75 */
76 protected function schedule_event() {
77 if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) {
78 wp_schedule_event( time() + 10, $this->cron_interval_identifier, $this->cron_hook_identifier );
79 }
80 }
81
82 /**
83 * Is the updater running?
84 *
85 * @return boolean
86 */
87 public function is_updating() {
88 return false === $this->is_queue_empty();
89 }
90
91 /**
92 * Task
93 *
94 * Override this method to perform any actions required on each
95 * queue item. Return the modified item for further processing
96 * in the next pass through. Or, return false to remove the
97 * item from the queue.
98 *
99 * @param string $callback Update callback function.
100 *
101 * @return mixed
102 */
103 protected function task( $callback ) {
104 if ( ! defined( 'SST_UPDATING' ) ) {
105 define( 'SST_UPDATING', true );
106 }
107
108 $logger = new WC_Logger();
109
110 require_once 'sst-update-functions.php';
111
112 $return = false;
113
114 if ( is_callable( $callback ) ) {
115 $logger->add( 'sst_db_updates', sprintf( 'Running %s callback', $callback ) );
116
117 $return = call_user_func( $callback );
118
119 $logger->add( 'sst_db_updates', sprintf( 'Finished %s callback', $callback ) );
120 } else {
121 $logger->add( 'sst_db_updates', sprintf( 'Could not find %s callback', $callback ) );
122 }
123
124 return $return;
125 }
126
127 /**
128 * Complete
129 *
130 * Override if applicable, but ensure that the below actions are
131 * performed, or, call parent::complete().
132 */
133 protected function complete() {
134 $logger = new WC_Logger();
135 $logger->add( 'sst_db_updates', 'Data update complete' );
136
137 update_option( 'wootax_version', SST()->version );
138
139 if ( ! class_exists( 'WC_Admin_Notices' ) ) {
140 require WC()->plugin_path() . '/admin/class-wc-admin-notices.php';
141 }
142
143 WC_Admin_Notices::remove_notice( 'sst_update' );
144
145 parent::complete();
146 }
147 }
148