first commit
This commit is contained in:
90
wp-content/plugins/yacht-booking-system/uninstall.php
Normal file
90
wp-content/plugins/yacht-booking-system/uninstall.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/**
|
||||
* Uninstall script
|
||||
*
|
||||
* Fired when the plugin is uninstalled.
|
||||
*
|
||||
* @package YachtBooking
|
||||
*/
|
||||
|
||||
// Exit if accessed directly or not uninstalling
|
||||
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete custom tables
|
||||
*/
|
||||
function yacht_booking_delete_tables() {
|
||||
global $wpdb;
|
||||
|
||||
$table_name = $wpdb->prefix . 'yacht_availability';
|
||||
$wpdb->query( "DROP TABLE IF EXISTS $table_name" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete plugin options
|
||||
*/
|
||||
function yacht_booking_delete_options() {
|
||||
delete_option( 'yacht_booking_version' );
|
||||
delete_option( 'yacht_booking_installed_at' );
|
||||
delete_option( 'yacht_booking_default_status' );
|
||||
delete_option( 'yacht_booking_email_from_name' );
|
||||
delete_option( 'yacht_booking_email_from' );
|
||||
delete_option( 'yacht_booking_email_from_address' );
|
||||
delete_option( 'yacht_booking_date_format' );
|
||||
delete_option( 'yacht_booking_currency_symbol' );
|
||||
delete_option( 'yacht_booking_terms_page_id' );
|
||||
delete_option( 'yacht_booking_email_templates' );
|
||||
delete_option( 'yacht_booking_enable_notifications' );
|
||||
delete_option( 'yacht_booking_gcal_sync_enabled' );
|
||||
delete_option( 'yacht_booking_gcal_token' );
|
||||
delete_option( 'yacht_booking_gcal_webhook_token' );
|
||||
delete_option( 'yacht_booking_gcal_credentials' );
|
||||
delete_option( 'yacht_booking_gcal_tokens' );
|
||||
delete_option( 'yacht_booking_gcal_calendar_id' );
|
||||
delete_option( 'yacht_booking_capabilities_added' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete custom post types
|
||||
*/
|
||||
function yacht_booking_delete_posts() {
|
||||
global $wpdb;
|
||||
|
||||
// Delete yacht posts
|
||||
$wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type = 'yacht'" );
|
||||
$wpdb->query( "DELETE FROM {$wpdb->postmeta} WHERE post_id NOT IN (SELECT ID FROM {$wpdb->posts})" );
|
||||
|
||||
// Delete booking posts
|
||||
$wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type = 'yacht_booking'" );
|
||||
$wpdb->query( "DELETE FROM {$wpdb->postmeta} WHERE post_id NOT IN (SELECT ID FROM {$wpdb->posts})" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove custom capabilities
|
||||
*/
|
||||
function yacht_booking_remove_capabilities() {
|
||||
$admin = get_role( 'administrator' );
|
||||
|
||||
if ( $admin ) {
|
||||
$capabilities = array(
|
||||
'yacht_booking_manage_yachts',
|
||||
'yacht_booking_manage_bookings',
|
||||
'yacht_booking_manage_settings',
|
||||
);
|
||||
|
||||
foreach ( $capabilities as $cap ) {
|
||||
$admin->remove_cap( $cap );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Run uninstall
|
||||
yacht_booking_delete_tables();
|
||||
yacht_booking_delete_options();
|
||||
yacht_booking_delete_posts();
|
||||
yacht_booking_remove_capabilities();
|
||||
|
||||
// Clean up transients
|
||||
delete_transient( 'yacht_booking_availability_cache' );
|
||||
Reference in New Issue
Block a user