Skip to content

Instantly share code, notes, and snippets.

@mindctrl
Created September 11, 2024 17:06
Show Gist options
  • Save mindctrl/43fd9c77416f2281d430d0df489aa076 to your computer and use it in GitHub Desktop.
Save mindctrl/43fd9c77416f2281d430d0df489aa076 to your computer and use it in GitHub Desktop.
Programmatically disable updates for specific WordPress plugins
<?php
/**
* Plugin Name: JP Plugin Update Disabler
* Description: Disables plugin updates for specified plugins.
* Version: 1.0
* Author: John Parris
*/
add_filter( 'http_request_args', 'jp_disable_plugin_updates', 10, 2 );
function jp_disable_plugin_updates( $args, $url ) {
if ( str_starts_with( $url, 'https://api.wordpress.org/plugins/update-check/1.1/' ) ) {
$blocked_plugins = [
'members/members.php',
];
$plugins = json_decode( $args['body']['plugins'], true );
foreach ( $blocked_plugins as $plugin ) {
if ( isset( $plugins['plugins'][ $plugin ] ) ) {
unset( $plugins['plugins'][ $plugin ] );
}
}
$args['body']['plugins'] = json_encode( $plugins );
}
return $args;
}
@mindctrl
Copy link
Author

Update the $blocked_plugins array for the plugins you want to target. Format is folder-name/main-plugin-filename.php.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment