PluginProbe
Tiered Pricing Table for WooCommerce / 2.0
Tiered Pricing Table for WooCommerce v2.0
7.1.7 7.1.5 7.1.4 7.1.1 6.5.0 6.4.0 6.1.0 trunk 1.0 1.1 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 All 90 releases
tier-pricing-table / src / BackgroundProcessing / Updater / Updates / VersionAbstract.php

VersionAbstract.php in Tiered Pricing Table for WooCommerce 2.0, at src/BackgroundProcessing/Updater/Updates/VersionAbstract.php

75 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace TierPricingTable\BackgroundProcessing\Updater\Updates;
2
3 use TierPricingTable\BackgroundProcessing\BackgroundTask;
4 use TierPricingTable\BackgroundProcessing\Updater\Updater;
5
6 abstract class VersionAbstract extends BackgroundTask {
7
8 protected $version;
9
10 public function getVersion() {
11 return $this->version;
12 }
13
14 protected function getIsCompletedUpdatingKey() {
15 return 'tiered_price_table_completed_updating_' . $this->getVersion();
16 }
17
18 protected function getIsUpdatingKey() {
19 return 'tiered_price_table_updating_' . $this->getVersion();
20 }
21
22 protected function isUpdating() {
23 return get_option( $this->getIsUpdatingKey() ) == 'yes';
24 }
25
26 protected function isCompleted() {
27 return get_option( $this->getIsCompletedUpdatingKey() ) == 'yes';
28 }
29
30 protected function begin() {
31 if ( ! $this->isUpdating() && ! $this->isCompleted() ) {
32 $this->push_to_queue( 'update_to_' . $this->getVersion() );
33
34 update_option( $this->getIsUpdatingKey(), 'yes' );
35
36 $this->save()->dispatch();
37 }
38 }
39
40 protected function complete() {
41 update_option( $this->getIsUpdatingKey(), 'no' );
42 update_option( $this->getIsCompletedUpdatingKey(), 'yes' );
43
44 $this->setCurrentDBVersion();
45 $this->showCompleteUpdatingMessage();
46
47 parent::complete();
48 }
49
50 protected function setCurrentDBVersion() {
51 update_option( Updater::DB_OPTION, $this->getVersion() );
52 }
53
54 protected function showUpdatingMessage() {
55 add_action( 'admin_notices', function () {
56 ?>
57 <div class="notice notice-info">
58 <p><?php _e( 'Tiered Pricing Table is updating database version. It may take a few minutes.',
59 'tier-pricing-table' ) ?></p>
60 </div>
61 <?php
62 } );
63 }
64
65 protected function showCompleteUpdatingMessage() {
66 add_action( 'admin_notices', function () {
67 ?>
68 <div class="notice notice-success">
69 <p><?php _e( 'Tiered Pricing Table has been completed updating database version.',
70 'tier-pricing-table' ) ?></p>
71 </div>
72 <?php
73 } );
74 }
75 }