Skip to content

Commit

Permalink
Use native autoload function
Browse files Browse the repository at this point in the history
  • Loading branch information
TorbenLundsgaard committed Nov 7, 2023
1 parent 138b667 commit 4f2b498
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions inc/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
}
Expand Down
8 changes: 6 additions & 2 deletions src/Installation/Activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'" );
}
}
}

0 comments on commit 4f2b498

Please sign in to comment.