Created
November 23, 2017 15:23
-
-
Save heldervilela/c9794f127e612071f6b5f2205147a531 to your computer and use it in GitHub Desktop.
Themeforest — Excluding your plugin or theme from update checks
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
# For plugins | |
function cws_hidden_plugin_12345( $r, $url ) { | |
if ( 0 !== strpos( $url, 'http://api.wordpress.org/plugins/update-check' ) ) | |
return $r; // Not a plugin update request. Bail immediately. | |
$plugins = unserialize( $r['body']['plugins'] ); | |
unset( $plugins->plugins[ plugin_basename( __FILE__ ) ] ); | |
unset( $plugins->active[ array_search( plugin_basename( __FILE__ ), $plugins->active ) ] ); | |
$r['body']['plugins'] = serialize( $plugins ); | |
return $r; | |
} | |
add_filter( 'http_request_args', 'cws_hidden_plugin_12345', 5, 2 ); | |
# For themes: | |
function cws_hidden_theme_12345( $r, $url ) { | |
if ( 0 !== strpos( $url, 'http://api.wordpress.org/themes/update-check' ) ) | |
return $r; // Not a theme update request. Bail immediately. | |
$themes = unserialize( $r['body']['themes'] ); | |
unset( $themes[ get_option( 'template' ) ] ); | |
unset( $themes[ get_option( 'stylesheet' ) ] ); | |
$r['body']['themes'] = serialize( $themes ); | |
return $r; | |
} | |
add_filter( 'http_request_args', 'cws_hidden_theme_12345', 5, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment