PluginProbe
Lasso Lite – Affiliate Link Manager & Product Displays / 111
Lasso Lite – Affiliate Link Manager & Product Displays v111
158 157 155 156 154 153 152 151 150 149 148 trunk 0.9.9 104 105 106 107 108 109 110 111 112 113 114 115 All 57 releases
← All changes | classes/class-update-db.php +5 -58 157111 View file →
@@ -6,17 +6,12 @@
6 6 */
7 7
8 8 namespace LassoLite\Classes;
9 9
10 -use LassoLite\Classes\Helper;
11 -
12 10 use LassoLite\Models\Amazon_Products;
13 -use LassoLite\Models\Model;
14 11 use LassoLite\Models\Url_Details;
15 12 use LassoLite\Models\Revert;
16 13
17 -use LassoLite\Classes\Setting;
18 -
19 14 /**
20 15 * Update_DB
21 16 */
22 17 class Update_DB {
@@ -24,15 +19,16 @@
24 19 * Update_DB constructor.
25 20 */
26 21 public function __construct() {
27 22
28 - if ( ! Helper::is_lite_using_new_ui() ) {
23 + if ( ! get_option( Enum::SWITCH_TO_NEW_UI ) ) {
29 24 return;
30 25 }
26 + $version = $this->get_version();
27 + if ( $version < 108 ) {
28 + $this->create_tables();
29 + }
31 30
32 - // ? Perform any additional schema changes and data updates/upgrades.
33 - $this->update_lasso_database();
34 -
35 31 $this->update_version();
36 32 }
37 33
38 34 /**
@@ -58,55 +54,6 @@
58 54 public static function create_tables() {
59 55 ( new Amazon_Products() )->create_table();
60 56 ( new Url_Details() )->create_table();
61 57 ( new Revert() )->create_table();
62 - }
63 -
64 -
65 - /**
66 - * Update database structure for new version
67 - */
68 - public function update_lasso_database() {
69 - $version = $this->get_version();
70 -
71 - if ( $version < 108 ) {
72 - $this->create_tables();
73 - }
74 -
75 - if ( $version < 113 ) {
76 - ( new Amazon_Products() )->create_table();
77 - $this->update_rating_and_review_data_from_aawp();
78 - }
79 -
80 - if ( $version < 129 ) {
81 - Setting::set_setting( 'auto_upgrade_eligible_links', true );
82 - }
83 -
84 - if ( $version < 152 && (int) LASSO_LITE_VERSION >= 152 ) {
85 - ( new Url_Details() )->update_for_v152();
86 - ( new Revert() )->update_for_v152();
87 - }
88 -
89 - // Beacon /js/e rewrite is registered in new code; upgrader runs the old callback.
90 - if ( $version < 154 && (int) LASSO_LITE_VERSION >= 154 ) {
91 - Helper::update_option( 'pending_vanity_rewrite_flush', '1' );
92 - }
93 - }
94 -
95 - /**
96 - * Update rating and reviews data from AAWP product table to Lasso amazon table, so we can support aawp fields shortcode
97 - */
98 - public function update_rating_and_review_data_from_aawp() {
99 - $lite_amazon_product_table = ( new Amazon_Products() )->get_table_name();
100 - $aawp_product_table = Model::get_wp_table_name( 'aawp_products' );
101 - if ( Model::table_exists( $aawp_product_table ) ) {
102 - $sql = '
103 - UPDATE ' . $lite_amazon_product_table . ' AS lap
104 - INNER JOIN ' . $aawp_product_table . ' AS aawpp ON lap.amazon_id = aawpp.asin
105 - SET lap.rating = IF(aawpp.rating IS NOT NULL, aawpp.rating, lap.rating),
106 - lap.reviews = IF(aawpp.reviews IS NOT NULL, aawpp.reviews, lap.reviews)
107 - ';
108 -
109 - Model::query( $sql );
110 - }
111 58 }
112 59 }