When I launched UUPD it was intended to be a totally reusable multi-plugin class and for the most part its already a big success having found my first plugin using our little updater class.
It’s been designed to be reusable, quick easy and free to update your free plugins directly from GitHub without the API limits and for that its working well but today I stumbled across something today that concerned me, someone has taken the UUPD updater.php and modified the class directly without rescoping the UUPD these changes are breaking changes that would cause serious issues to other users of UUPD.
Now I have submitted a pull request to this repo and explained the issues and hopefully they will understand or at least confirm they are playing and don’t intend to release this into the wild with an un rescoped version.
What’s rescoping?
Rescoping is Renaming the namespace and class(es) to avoid conflicts with other plugins using the original version.
Why it matters:
- Prevents namespace/class collisions with other plugins using
\UUPD\V1\UUPD_Updater_V1
- Lets you customise or extend the logic independently (e.g. new features, different cache logic)
- Allows side-by-side coexistence with other plugins using older or stock UUPD versions
You don’t need to rescope!
You don’t need to rescope if your not making breaking changes the UUPD class is designed to work on an unlimited number of plugins from as many different authors as you want too. The first version is loaded and from there you can all slot into it and this is how name spacing and classes are designed to work.
If you are changing the base logic though you should rescope and as it is likely I will be using cutting edge features within my plugins I have decided to rescope a version for Really Useful Plugins plugins after all I already have over two dozen plugins running UUPD it makes sense to isolate mine from everyone else’s as I can do testing.
Its not hard to rescope UUPD
It really not hard to rescope UUPD its a very lightweight script and me being me I wanted to do this with some automation so I set up the following workflow in a rescoping repo.

- this is where the rescoped updater.php will be deposited
- this is where the original updater.php goes
- destinations is where the rescoped updater.php need to be copied to i.e all the palces it needs to be deployed too where I am using UUPD for an update
- The Bat File below to create the rescoping
- the PHP file that does all the work.
Now I use windows so I am using a BAT file but you could equally do the same with a sh file on mac or Linux and its important to note that I have PHP running on the path too.
Destingations.txt contains an individual line per location to desposit the rescoped file in the following format C:\Git\RUPChangelog\rup-changelogger\includes
The contents of rescope.bat just tells you how to rescope with three variables to send to the PHP file to run
@echo off
setlocal enabledelayedexpansion
:: ===================================
:: CONFIGURATION - EDIT THESE VALUES
:: ===================================
set VENDOR=RUP
set MODULE=Updater
set CLASSNAME=Updater_V1
:: Run PHP script with hardcoded values
php rescope-uupd.php %VENDOR% %MODULE% %CLASSNAME%
pause
BAT (Batchfile)
the rescope-uupd.php contains the following code
<?php
if ($argc < 4) {
echo "Usage: php rescope-uupd.php <VENDOR> <MODULE> <CLASSNAME>\n";
exit(1);
}
$vendor = $argv[1]; // e.g. RUP
$module = $argv[2]; // e.g. Updater
$class_name = $argv[3]; // e.g. Updater_V1
$old_ns = 'UUPD\\V1';
$new_ns = "$vendor\\$module";
$old_class = 'UUPD_Updater_V1';
$new_class = $class_name;
$old_transient = 'upd_';
$new_transient = strtolower($vendor) . '_';
$old_filter = 'uupd_';
$new_filter = strtolower($vendor) . '_';
$source_file = __DIR__ . '/sources/updater.php';
$output_dir = __DIR__ . '/output';
//$output_file = "$output_dir/" . strtolower($vendor) . '-updater.php';
$output_file = "$output_dir/updater.php";
if (!file_exists($source_file)) {
echo "Source file not found: $source_file\n";
exit(1);
}
if (!is_dir($output_dir)) {
mkdir($output_dir, 0777, true);
}
$code = file_get_contents($source_file);
$replacements = [
$old_ns => $new_ns,
$old_class => $new_class,
$old_transient => $new_transient,
$old_filter => $new_filter,
];
foreach ($replacements as $from => $to) {
$code = str_replace($from, $to, $code);
}
file_put_contents($output_file, $code);
echo "Rescoped file saved to: $output_file\n";
$dest_file_list = __DIR__ . '/destinations.txt';
if (file_exists($dest_file_list)) {
$paths = file($dest_file_list, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($paths as $path) {
$target = rtrim($path, '/\\') . '/' . basename($output_file);
if (!is_dir(dirname($target))) {
mkdir(dirname($target), 0777, true);
}
copy($output_file, $target);
echo " Copied to: $target\n";
}
}
PHP
this effectively gives me my own version of UUPD and allows me to call in uniquely so instead of \UUPD\V1\UUPD_Updater_V1::register( $updater_config );
i get to use \RUP\Updater\Updater_V1::register( $updater_config );
and know that I am calling my own version of UUPD that means I can run advanced or cutting edge version code without effecting anyone else’s use of UUPD.
So please if your modifying UUPD directly please scope it and I hope the above article can be useful as a guide. you can get UUPD from Github https://github.com/stingray82/UUPD