diff --git a/inc/main.php b/inc/main.php index 0eb3175..e5904b9 100644 --- a/inc/main.php +++ b/inc/main.php @@ -49,9 +49,13 @@ function gtmkit_plugin_activation(): void { * Plugin activation hook. */ function gtmkit_plugin_deactivation(): void { - global $wpdb; - $wpdb->query( "UPDATE $wpdb->options SET autoload = 'no' WHERE option_name = 'gtmkit'" ); + if ( function_exists( 'wp_set_option_autoload' ) ) { + wp_set_option_autoload( 'gtmkit', 'no' ); + } else { + global $wpdb; + $wpdb->query( "UPDATE $wpdb->options SET autoload = 'no' WHERE option_name = 'gtmkit'" ); + } wp_clear_scheduled_hook( 'gtmkit_send_anonymous_data' ); } diff --git a/src/Installation/Activation.php b/src/Installation/Activation.php index 5bb92af..a7ee164 100644 --- a/src/Installation/Activation.php +++ b/src/Installation/Activation.php @@ -52,8 +52,12 @@ public function set_first_install_options(): void { * Set autoload on options. */ public function set_autoload_on_options(): void { - global $wpdb; - $wpdb->query( "UPDATE $wpdb->options SET autoload = 'yes' WHERE option_name = 'gtmkit'" ); + if ( function_exists( 'wp_set_option_autoload' ) ) { + wp_set_option_autoload( 'gtmkit', 'yes' ); + } else { + global $wpdb; + $wpdb->query( "UPDATE $wpdb->options SET autoload = 'yes' WHERE option_name = 'gtmkit'" ); + } } }