Integrate plugin update checker library

Added the Plugin Update Checker library under lib/plugin-update-checker and integrated it into WPSlug_Core for automatic update checks. This enables update notifications and management for the plugin via a remote JSON metadata file.
This commit is contained in:
feibisi 2025-07-15 12:36:48 +08:00
parent 6ab770bc41
commit c4e6027779
125 changed files with 13129 additions and 1 deletions

View file

@ -19,6 +19,7 @@ class WPSlug_Core {
$this->admin = new WPSlug_Admin();
}
$this->init_update_checker();
$this->initHooks();
}
@ -40,6 +41,28 @@ class WPSlug_Core {
add_action('manage_pages_custom_column', array($this, 'displaySlugColumn'), 10, 2);
}
}
private function init_update_checker()
{
if (
file_exists(
plugin_dir_path(__FILE__) .
"../lib/plugin-update-checker/plugin-update-checker.php"
)
) {
require_once plugin_dir_path(__FILE__) .
"../lib/plugin-update-checker/plugin-update-checker.php";
if (
class_exists('YahnisElsts\PluginUpdateChecker\v5p3\PucFactory')
) {
$this->update_checker = \YahnisElsts\PluginUpdateChecker\v5p3\PucFactory::buildUpdateChecker(
"https://updates.weixiaoduo.com/wpslug.json",
WPSLUG_PLUGIN_DIR . "wpslug.php",
"wpslug"
);
}
}
}
public function processSanitizeTitle($title, $raw_title = '', $context = 'display') {
if ($context !== 'save' || empty($title)) {