PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.84
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.84
5.5.84 5.5.83 5.5.82 5.5.81 5.5.80 5.5.79 5.5.77 5.5.76 5.5.75 5.5.73 5.5.72 5.5.22 5.5.23 5.5.29 5.5.3 5.5.31 5.5.32 5.5.34 5.5.35 5.5.36 5.5.37 5.5.4 5.5.40 5.5.41 5.5.42 All 160 releases
← All changes | includes/class-wp-data-access-switch.php +34 -58 5.5.425.5.84 View file →
@@ -29,8 +29,9 @@
29 29 *
30 30 * @see WP_Data_Access_Switch::activate()
31 31 * @see WP_Data_Access_Switch::deactivate()
32 32 */
33 +// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound
33 34 class WP_Data_Access_Switch {
34 35 /**
35 36 * Activate plugin WP Data Access
36 37 *
@@ -54,10 +55,11 @@
54 55 // Activate plugin.
55 56 if ( is_multisite() ) {
56 57 global $wpdb;
57 58 // Multisite installation.
59 + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
58 60 $blogids = $wpdb->get_col( "select blog_id from {$wpdb->blogs}" );
59 - // db call ok; no-cache ok.
61 + // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
60 62 foreach ( $blogids as $blog_id ) {
61 63 // Activate blog.
62 64 switch_to_blog( $blog_id );
63 65 self::activate_blog();
@@ -140,10 +142,11 @@
140 142 // Deactivate plugin.
141 143 if ( is_multisite() ) {
142 144 global $wpdb;
143 145 // Multisite installation.
146 + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
144 147 $blogids = $wpdb->get_col( "select blog_id from {$wpdb->blogs}" );
145 - // db call ok; no-cache ok.
148 + // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
146 149 foreach ( $blogids as $blog_id ) {
147 150 // Deactivate blog.
148 151 switch_to_blog( $blog_id );
149 152 self::flush_rewrite_rules();
@@ -156,75 +159,48 @@
156 159 }
157 160 }
158 161
159 162 private static function flush_rewrite_rules() {
160 - // Unscheduled all WP Data Access events
161 - self::unschedule_event( 'wpda_data_backup' );
162 - self::unschedule_event( \WPDataAccess\Query_Builder\WPDA_Query_Builder_Scheduler::SCHEDULER_HOOK_NAME );
163 - self::unschedule_event( \WPDataAccess\Utilities\WPDA_Export_Scheduler::SCHEDULER_HOOK_NAME );
164 163 }
165 164
166 - private static function unschedule_event( $hook ) {
167 - $crons = _get_cron_array();
168 - foreach ( $crons as $timestamp => $cron ) {
169 - if ( isset( $cron[$hook] ) ) {
170 - foreach ( $cron[$hook] as $event ) {
171 - if ( isset( $event['args'] ) ) {
172 - wp_unschedule_event( $timestamp, $hook, $event['args'] );
173 - }
174 - }
175 - }
176 - }
177 - }
178 -
179 165 private static function set_legacy_tools() {
180 166 // Get current legacy tool settings
181 167 $stored_legacy_tools = get_option( 'wpda_plugin_legacy_tools' );
182 - $option_legacy_tools = \WPDataAccess\Utilities\WPDA_Legacy_Tool_Visibility::get();
183 - // Update legacy tool settings
184 - if ( 0 === $option_legacy_tools['tables'] ) {
185 - $option_legacy_tools['tables'][0] = false;
186 - } else {
187 - if ( false === $stored_legacy_tools ) {
188 - $option_legacy_tools['tables'][0] = true;
168 + if ( false === $stored_legacy_tools ) {
169 + // Use default for fresh installation
170 + // Update if legacy tool is actively used
171 + $option_legacy_tools = \WPDataAccess\Utilities\WPDA_Legacy_Tool_Visibility::get();
172 + $option_updated = false;
173 + if ( 0 < $option_legacy_tools['tables'][1] ) {
174 + $option_legacy_tools['tables'] = array(true, $option_legacy_tools['tables'][1]);
175 + $option_updated = true;
189 176 }
190 - }
191 - if ( 0 === $option_legacy_tools['forms'] ) {
192 - $option_legacy_tools['forms'][0] = false;
193 - } else {
194 - if ( false === $stored_legacy_tools ) {
195 - $option_legacy_tools['forms'][0] = true;
177 + if ( 0 < $option_legacy_tools['forms'][1] ) {
178 + $option_legacy_tools['forms'] = array(true, $option_legacy_tools['forms'][1]);
179 + $option_updated = true;
196 180 }
197 - }
198 - if ( 0 === $option_legacy_tools['templates'] ) {
199 - $option_legacy_tools['templates'][0] = false;
200 - } else {
201 - if ( false === $stored_legacy_tools ) {
202 - $option_legacy_tools['templates'][0] = true;
181 + if ( 0 < $option_legacy_tools['templates'][1] ) {
182 + $option_legacy_tools['templates'] = array(true, $option_legacy_tools['templates'][1]);
183 + $option_updated = true;
203 184 }
204 - }
205 - if ( 0 === $option_legacy_tools['designer'] ) {
206 - $option_legacy_tools['designer'][0] = false;
207 - } else {
208 - if ( false === $stored_legacy_tools ) {
209 - $option_legacy_tools['designer'][0] = true;
185 + if ( 0 < $option_legacy_tools['designer'][1] ) {
186 + $option_legacy_tools['designer'] = array(true, $option_legacy_tools['designer'][1]);
187 + $option_updated = true;
210 188 }
211 - }
212 - if ( 0 === $option_legacy_tools['dashboards'] ) {
213 - $option_legacy_tools['dashboards'][0] = false;
214 - } else {
215 - if ( false === $stored_legacy_tools ) {
216 - $option_legacy_tools['dashboards'][0] = true;
189 + if ( 0 < $option_legacy_tools['dashboards'][1] ) {
190 + $option_legacy_tools['dashboards'] = array(true, $option_legacy_tools['dashboards'][1]);
191 + $option_updated = true;
217 192 }
218 - }
219 - if ( 0 === $option_legacy_tools['charts'] ) {
220 - $option_legacy_tools['charts'][0] = false;
221 - } else {
222 - if ( false === $stored_legacy_tools ) {
223 - $option_legacy_tools['charts'][0] = true;
193 + if ( 0 < $option_legacy_tools['charts'][1] ) {
194 + $option_legacy_tools['charts'] = array(true, $option_legacy_tools['charts'][1]);
195 + $option_updated = true;
224 196 }
197 + if ( $option_updated ) {
198 + // Save legacy tool settings.
199 + WPDA::set_option( WPDA::OPTION_PLUGIN_LEGACY_TOOLS, $option_legacy_tools );
200 + }
225 201 }
226 - // Save legacy tool settings.
227 - WPDA::set_option( WPDA::OPTION_PLUGIN_LEGACY_TOOLS, $option_legacy_tools );
228 202 }
229 203
230 204 }
205 +
206 +// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound