| @@ -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,27 +159,10 @@ | ||
| 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 | 168 | if ( false === $stored_legacy_tools ) { |
| @@ -215,4 +201,6 @@ | ||
| 215 | 201 | } |
| 216 | 202 | } |
| 217 | 203 | |
| 218 | 204 | } |
| 205 | + | |
| 206 | +// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound | |