Skip to content

Instantly share code, notes, and snippets.

@ironprogrammer
Last active June 27, 2023 23:11
Show Gist options
  • Save ironprogrammer/1aaff6f60b263c1842e3584365729ffc to your computer and use it in GitHub Desktop.
Save ironprogrammer/1aaff6f60b263c1842e3584365729ffc to your computer and use it in GitHub Desktop.
Trac 57662 test plugin -- enables custom WordPress package update
<?php
/**
* Plugin Name: Fake WordPress Update
* Description: Filters the value of <code>site_transient_update_core</code> to allow a custom install package.
* Author: WordPress Core Contributors
* Author URI: https://make.wordpress.org/core
* License: GPLv2 or later
* Version: 1.0.0
*
* Adapted from https://gist.githubusercontent.com/hellofromtonya/bb0aa2d4b2311c8b40fa5ae8ada4dc19
*/
add_filter(
'site_transient_update_core',
function ( $value ) {
if ( ! isset( $value->updates ) ) {
return $value;
}
$fake_update_location = trailingslashit( get_bloginfo( 'url' ) ) . 'wordpress-custom.zip';
$fake_update = (object) array(
'response' => 'upgrade',
'download' => $fake_update_location,
'locale' => 'en_US',
'packages' =>
(object) array(
'full' => $fake_update_location,
'no_content' => $fake_update_location,
'new_bundled' => $fake_update_location,
'partial' => '',
'rollback' => '',
),
'current' => '6.3.0-custom',
'version' => '6.3.0-custom',
'php_version' => '5.6.20',
'mysql_version' => '5.0',
'new_bundled' => '6.3',
'partial_version' => '',
'version_checked' => '',
);
array_unshift( $value->updates, $fake_update );
return $value;
}
);
@ironprogrammer
Copy link
Author

On 2023-06-27 updated plugin to fake version 6.3.0-custom for Trac 58206 testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment