-
-
Save jentanbernardus/e975eb8b255de9567e2b to your computer and use it in GitHub Desktop.
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 | |
/** | |
* How to integrate WordPress Core updates with your custom Plugin or Theme | |
* | |
* Filter the `update_plugins` transient to report your plugin as out of date. | |
* Themes have a similar transient you can filter. | |
*/ | |
add_filter( 'site_transient_update_plugins', 'wprp_extend_filter_update_plugins' ); | |
add_filter( 'transient_update_plugins', 'wprp_extend_filter_update_plugins' ); | |
function wprp_extend_filter_update_plugins( $update_plugins ) { | |
if ( ! is_object( $update_plugins ) ) | |
return $update_plugins; | |
if ( ! isset( $update_plugins->response ) || ! is_array( $update_plugins->response ) ) | |
$update_plugins->response = array(); | |
// Do whatever you need to see if there's a new version of your plugin | |
// Your response will need to look something like this if it's out of date: | |
$update_plugins->response['wpremote-sample/wpremote-sample.php'] = (object)array( | |
'slug' => 'wpremote-sample', // Whatever you want, as long as it's not on WordPress.org | |
'new_version' => '0.2', // The newest version | |
'url' => 'https://github.com/humanmade/wp-remote-sample-plugin', // Informational | |
'package' => 'https://github.com/humanmade/wp-remote-sample-plugin/archive/0.2.zip', // Where WordPress should pull the ZIP from. | |
); | |
return $update_plugins; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment