PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.2
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.2
5.5.85 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 All 161 releases
← All changes | includes/class-wp-data-access-switch.php +53 -98 5.5.415.2 View file →
@@ -4,20 +4,19 @@
4 4 * Suppress "error - 0 - No summary was found for this file" on phpdoc generation
5 5 *
6 6 * @package plugin\includes
7 7 */
8 -use WPDataAccess\Plugin_Table_Models\WPDA_Design_Table_Model;
9 -use WPDataAccess\Plugin_Table_Models\WPDA_Logging_Model;
10 -use WPDataAccess\Plugin_Table_Models\WPDA_Media_Model;
11 -use WPDataAccess\Plugin_Table_Models\WPDA_Publisher_Model;
12 -use WPDataAccess\Plugin_Table_Models\WPDA_Table_Settings_Model;
13 -use WPDataAccess\Plugin_Table_Models\WPDA_User_Menus_Model;
14 -use WPDataAccess\Plugin_Table_Models\WPDP_Page_Model;
15 -use WPDataAccess\Plugin_Table_Models\WPDP_Project_Model;
16 -use WPDataAccess\Plugin_Table_Models\WPDP_Project_Design_Table_Model;
17 -use WPDataAccess\Premium\WPDAPRO_Dashboard\WPDAPRO_Dashboard;
18 -use WPDataAccess\Utilities\WPDA_Repository;
19 -use WPDataAccess\WPDA;
8 +use WPDataAccess\Plugin_Table_Models\WPDA_Design_Table_Model ;
9 +use WPDataAccess\Plugin_Table_Models\WPDA_Logging_Model ;
10 +use WPDataAccess\Plugin_Table_Models\WPDA_Media_Model ;
11 +use WPDataAccess\Plugin_Table_Models\WPDA_Publisher_Model ;
12 +use WPDataAccess\Plugin_Table_Models\WPDA_Table_Settings_Model ;
13 +use WPDataAccess\Plugin_Table_Models\WPDA_User_Menus_Model ;
14 +use WPDataAccess\Plugin_Table_Models\WPDP_Page_Model ;
15 +use WPDataAccess\Plugin_Table_Models\WPDP_Project_Model ;
16 +use WPDataAccess\Plugin_Table_Models\WPDP_Project_Design_Table_Model ;
17 +use WPDataAccess\Utilities\WPDA_Repository ;
18 +use WPDataAccess\WPDA ;
20 19 /**
21 20 * Class WP_Data_Access_Switch
22 21 *
23 22 * Switch to:
@@ -29,9 +28,10 @@
29 28 *
30 29 * @see WP_Data_Access_Switch::activate()
31 30 * @see WP_Data_Access_Switch::deactivate()
32 31 */
33 -class WP_Data_Access_Switch {
32 +class WP_Data_Access_Switch
33 +{
34 34 /**
35 35 * Activate plugin WP Data Access
36 36 *
37 37 * The user must have the appropriate privileges to perform this operation.
@@ -48,18 +48,21 @@
48 48 * @since 1.0.0
49 49 *
50 50 * @see WP_Data_Access_Switch::activate_blog()
51 51 */
52 - public static function activate() {
52 + public static function activate()
53 + {
54 +
53 55 if ( current_user_can( 'activate_plugins' ) ) {
54 56 // Activate plugin.
57 +
55 58 if ( is_multisite() ) {
56 - global $wpdb;
59 + global $wpdb ;
57 60 // Multisite installation.
58 61 $blogids = $wpdb->get_col( "select blog_id from {$wpdb->blogs}" );
59 62 // db call ok; no-cache ok.
60 63 foreach ( $blogids as $blog_id ) {
61 - // Activate blog.
64 + // Uninstall blog.
62 65 switch_to_blog( $blog_id );
63 66 self::activate_blog();
64 67 restore_current_blog();
65 68 }
@@ -66,11 +69,18 @@
66 69 } else {
67 70 // Single site installation.
68 71 self::activate_blog();
69 72 }
73 +
74 + /*
75 + } else {
76 + // This blocks the site on unattended plugin update! (support topic 11472418 - tjgorman)
77 + // wp_die( __( 'ERROR: Not authorized', 'wp-data-access' ) );
78 + */
70 79 }
80 +
71 81 }
72 -
82 +
73 83 /**
74 84 * Activate blog
75 85 *
76 86 * The user must have the appropriate privileges to perform this operation.
@@ -92,23 +102,31 @@
92 102 *
93 103 * @see WPDA::set_option()
94 104 * @see WPDA_Repository::create()
95 105 */
96 - protected static function activate_blog() {
106 + protected static function activate_blog()
107 + {
108 +
97 109 if ( current_user_can( 'activate_plugins' ) ) {
110 +
98 111 if ( get_option( WPDataAccess\WPDA::OPTION_WPDA_VERSION[0] ) !== WPDataAccess\WPDA::OPTION_WPDA_VERSION[1] ) {
99 112 self::recreate_repository();
100 113 } elseif ( !WPDA_User_Menus_Model::table_exists() || !WPDA_Design_Table_Model::table_exists() || !WPDP_Project_Design_Table_Model::table_exists() || !WPDA_Publisher_Model::table_exists() || !WPDA_Logging_Model::table_exists() || !WPDA_Media_Model::table_exists() || !WPDP_Project_Model::table_exists() || !WPDP_Page_Model::table_exists() || !WPDA_Table_Settings_Model::table_exists() ) {
101 114 self::recreate_repository();
102 115 }
116 +
103 117 if ( wpda_freemius()->is_free_plan() ) {
104 118 update_option( 'wpda_fulltext_support', 'off' );
105 119 }
106 - self::flush_rewrite_rules();
107 - self::set_legacy_tools();
120 + /*
121 + } else {
122 + // This blocks the site on unattended plugin update! (support topic 11472418 - tjgorman)
123 + // wp_die( __( 'ERROR: Not authorized', 'wp-data-access' ) );
124 + */
108 125 }
126 +
109 127 }
110 -
128 +
111 129 /**
112 130 * (re)create plugin repository
113 131 *
114 132 * If no repository is found, a new one is created
@@ -113,20 +131,22 @@
113 131 *
114 132 * If no repository is found, a new one is created
115 133 * If a repository is found, the table structures are update and the data transferred
116 134 */
117 - protected static function recreate_repository() {
135 + protected static function recreate_repository()
136 + {
118 137 $wpda_repository = new WPDA_Repository();
119 138 $wpda_repository->recreate();
120 139 // Save (new) plugin version.
121 140 WPDA::set_option( WPDA::OPTION_WPDA_VERSION );
141 + // Show link to "What's New?" page on plugin pages in WordPress dashboard.
142 + WPDA::set_option( WPDA::OPTION_WPDA_SHOW_WHATS_NEW, 'on' );
122 143 // Create content folder to store CSV and cache files.
123 144 WPDA::wpda_create_content_folder();
124 145 // Generate new sonce seed on every update.
125 146 WPDA::set_option( WPDA::OPTION_PLUGIN_SONCE_SEED, bin2hex( openssl_random_pseudo_bytes( wp_rand( 40, 60 ) ) ) );
126 - WPDA::set_option( WPDA::OPTION_WPDA_UPGRADED, true );
127 147 }
128 -
148 +
129 149 /**
130 150 * Deactivate plugin WP Data Access
131 151 *
132 152 * On deactivation we leave the repository and options as they are in case the user wants to reactivate the
@@ -134,80 +154,15 @@
134 154 * on uninstall change plugin settings (see uninstall settings).
135 155 *
136 156 * @since 1.0.0
137 157 */
138 - public static function deactivate() {
139 - if ( current_user_can( 'activate_plugins' ) ) {
140 - // Deactivate plugin.
141 - if ( is_multisite() ) {
142 - global $wpdb;
143 - // Multisite installation.
144 - $blogids = $wpdb->get_col( "select blog_id from {$wpdb->blogs}" );
145 - // db call ok; no-cache ok.
146 - foreach ( $blogids as $blog_id ) {
147 - // Deactivate blog.
148 - switch_to_blog( $blog_id );
149 - self::flush_rewrite_rules();
150 - restore_current_blog();
151 - }
152 - } else {
153 - // Single site installation.
154 - self::flush_rewrite_rules();
155 - }
156 - }
158 + public static function deactivate()
159 + {
160 + /*
161 + // if ( ! current_user_can( 'activate_plugins' ) ) {
162 + // This blocks the site on unattended plugin update! (support topic 11472418 - tjgorman)
163 + // wp_die( __( 'ERROR: Not authorized', 'wp-data-access' ) );
164 + // }
165 + */
157 166 }
158 167
159 - private static function flush_rewrite_rules() {
160 - }
161 -
162 - private static function set_legacy_tools() {
163 - // Get current legacy tool settings
164 - $stored_legacy_tools = get_option( 'wpda_plugin_legacy_tools' );
165 - $option_legacy_tools = \WPDataAccess\Utilities\WPDA_Legacy_Tool_Visibility::get();
166 - // Update legacy tool settings
167 - if ( 0 === $option_legacy_tools['tables'] ) {
168 - $option_legacy_tools['tables'][0] = false;
169 - } else {
170 - if ( false === $stored_legacy_tools ) {
171 - $option_legacy_tools['tables'][0] = true;
172 - }
173 - }
174 - if ( 0 === $option_legacy_tools['forms'] ) {
175 - $option_legacy_tools['forms'][0] = false;
176 - } else {
177 - if ( false === $stored_legacy_tools ) {
178 - $option_legacy_tools['forms'][0] = true;
179 - }
180 - }
181 - if ( 0 === $option_legacy_tools['templates'] ) {
182 - $option_legacy_tools['templates'][0] = false;
183 - } else {
184 - if ( false === $stored_legacy_tools ) {
185 - $option_legacy_tools['templates'][0] = true;
186 - }
187 - }
188 - if ( 0 === $option_legacy_tools['designer'] ) {
189 - $option_legacy_tools['designer'][0] = false;
190 - } else {
191 - if ( false === $stored_legacy_tools ) {
192 - $option_legacy_tools['designer'][0] = true;
193 - }
194 - }
195 - if ( 0 === $option_legacy_tools['dashboards'] ) {
196 - $option_legacy_tools['dashboards'][0] = false;
197 - } else {
198 - if ( false === $stored_legacy_tools ) {
199 - $option_legacy_tools['dashboards'][0] = true;
200 - }
201 - }
202 - if ( 0 === $option_legacy_tools['charts'] ) {
203 - $option_legacy_tools['charts'][0] = false;
204 - } else {
205 - if ( false === $stored_legacy_tools ) {
206 - $option_legacy_tools['charts'][0] = true;
207 - }
208 - }
209 - // Save legacy tool settings.
210 - WPDA::set_option( WPDA::OPTION_PLUGIN_LEGACY_TOOLS, $option_legacy_tools );
211 - }
212 -
213 -}
168 +}