Created
September 11, 2024 17:06
-
-
Save mindctrl/43fd9c77416f2281d430d0df489aa076 to your computer and use it in GitHub Desktop.
Programmatically disable updates for specific WordPress plugins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Update the
$blocked_plugins
array for the plugins you want to target. Format isfolder-name/main-plugin-filename.php
.