Skip to content

Instantly share code, notes, and snippets.

@scofennell
Created December 22, 2016 23:42
Show Gist options
  • Save scofennell/65030712b59fa38591c0db87c8206783 to your computer and use it in GitHub Desktop.
Save scofennell/65030712b59fa38591c0db87c8206783 to your computer and use it in GitHub Desktop.
Inject a Bitbucket repo into the WordPress updates UI.
<?php
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'set_plugin_transient' ) );
/**
* Inject our updates into core's list of updates.
*
* @param array $transient The existing list of assets that need an update.
* @return The list of assets that need an update, filtered.
*/
public function set_plugin_transient( $transient ) {
if( ! is_array( $this -> assets_to_update ) ) { return $transient; }
foreach( $this -> assets_to_update as $asset ) {
if( empty( $asset -> transient_key ) ) { continue; }
if( ! $asset -> transient_content ) { continue; }
$transient -> response[ $asset -> transient_key ] = $asset -> transient_content;
}
return $transient;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment