Open stingray82 opened 2 months ago
I think I've done this, I still need to test thoroughly. I've added a custom-plugin-handler.php in the root directory, and modified the includes/Wpup/UpdateServer.php I have forked and uploaded here if someone else wants this https://github.com/stingray82/wp-update-server
FWIW, I did look at the fork but couldn't figure out what it has to do with the text domain (the code doesn't mention "domain" or "language"), so I don't have any useful suggestions for this issue. I guess if it works 🤷
Maybe I did a poor job of explaining it, I have some plugins which when looking on the server look for Pluginname.zip and actually there folder and basic structure is actually pluginname-plugin.zip, this wasn't an issue when I was pushing and uploading them all manually but has been an issue when I added some automation, so new versions are pushed downloaded, zipped and uploaded to my custom repo it was causing me issues with updates
$custom_plugins = array( 'my-custom' => array( 'zip_path' => __DIR__ . '/packages/my-custom-plugin.zip', 'main_file' => 'my-custom-plugin/my-custom-plugin.php', ), );
Hmm, if the slug => filename conversion is predictable, you might also be able to implement this by changing the findPackage
method. The current implementation looks for slug.zip, but technically you could pass any valid ZIP filename to the package loader callback. This way you might not need to manually list every custom plugin. However, that's just an alternative idea.
I will look into that anything that makes it super easy to maintain I am up for so will definitely take a look at that
Thanks for that its much more efficient and allows me to just add any new ones there, code is below in case its of use to anyone else, still testing it but it appears to be working; ` //Stingray82 Modification protected function findPackage($slug) { // Sanitize the slug to ensure it's safe for file handling $safeSlug = pregreplace('@[^a-z0-9-.,+!]@i', '', $slug);
// Define an array of possible modifiers for the filename
$modifiers = array(
'', // Standard slug.zip
'-plugin', // slug-plugin.zip
'-tweaks-and-updates', // Tweak files
// Add more modifiers here as needed
);
// Loop through each modifier and attempt to find the corresponding ZIP file
foreach ($modifiers as $modifier) {
$filename = $this->packageDirectory . '/' . $safeSlug . $modifier . '.zip';
// Log the attempt to find the file
//error_log("Looking for package file: " . $filename); // Only needed for error handling
// If the file is found and readable, return it
if (is_file($filename) && is_readable($filename)) {
return call_user_func($this->packageFileLoader, $filename, $slug, $this->cache);
}
}
// If no files are found, return null
return null;
} //End Stingray82 Modification`
Is it possible to make the update checker check both slug and text domain? I've tried a htaccess redirect from one to the other but that works for a browser but not for the server is it possible to modify it to do both? so as an example
Example: Bones-plugin.zip is checked and returned even if it is looking for bones.zip?
any suggestions would be appreciated