Skip to content

Instantly share code, notes, and snippets.

@afragen
Last active February 11, 2021 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afragen/2ed3f5a3d8c3ecca74955fa30fcb82e7 to your computer and use it in GitHub Desktop.
Save afragen/2ed3f5a3d8c3ecca74955fa30fcb82e7 to your computer and use it in GitHub Desktop.
Prevent updating for specific WordPress plugins.
<?php
// Prevent updating of specific dot org plugins.
add_filter(
'site_transient_update_plugins',
function( $transient ) {
$plugin_arr = [ 'test-plugin2/test-plugin2.php', 'akismet/akismet.php' ];
foreach ( $plugin_arr as $plugin_file ) {
if ( isset( $transient->response[ $plugin_file ]->id )
&& false !== strpos( $transient->response[ $plugin_file ]->id, 'w.org/plugins' )
) {
unset( $transient->response[ $plugin_file ] );
}
}
return $transient;
},
99,
1
);
<?php
// Prevent updating of specific plugins.
add_filter(
'site_transient_update_plugins',
function( $transient ) {
$plugin_arr = [ 'test-plugin2/test-plugin2.php', 'akismet/akismet.php' ];
foreach ( $plugin_arr as $plugin_file ) {
if ( isset( $transient->response[ $plugin_file ] ) ) {
unset( $transient->response[ $plugin_file ] );
}
}
return $transient;
},
99,
1
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment