c2c6d90f0c
- get_sites() returns 100 sites by default; with 'number' => 0 the index table and option are dropped on every site of the network - Verify: php -l; phpcs unchanged (1 existing error on the DROP TABLE line) - PR: PR-100
38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* Uninstall handler for 2meet Data Optimizer Latepoint AddOn.
|
|
*
|
|
* 僅清理本 AddOn 自有 schema(核心 wp_wpdo_* 系統表保留給 core)。
|
|
*
|
|
* @package TMDO_LATEPOINT
|
|
*/
|
|
|
|
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
|
exit;
|
|
}
|
|
|
|
// wp_hpct_latepoint_idx is an index rebuilt from LatePoint's own bookings, so
|
|
// dropping it loses no data; LatePoint's tables are left untouched.
|
|
global $wpdb;
|
|
|
|
// 'number' => 0: get_sites() returns only 100 sites by default.
|
|
$tmdo_latepoint_blogs = is_multisite()
|
|
? get_sites(
|
|
array(
|
|
'fields' => 'ids',
|
|
'number' => 0,
|
|
)
|
|
)
|
|
: array( get_current_blog_id() );
|
|
foreach ( $tmdo_latepoint_blogs as $tmdo_latepoint_blog ) {
|
|
if ( is_multisite() ) {
|
|
switch_to_blog( $tmdo_latepoint_blog );
|
|
}
|
|
$tmdo_latepoint_table = $wpdb->prefix . 'hpct_latepoint_idx';
|
|
$wpdb->query( "DROP TABLE IF EXISTS `{$tmdo_latepoint_table}`" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.DirectDatabaseQuery.SchemaChange
|
|
delete_option( 'tmdo_latepoint_db_version' );
|
|
if ( is_multisite() ) {
|
|
restore_current_blog();
|
|
}
|
|
}
|