YahnisElsts / plugin-update-checker

A custom update checker for WordPress plugins. Useful if you don't want to host your project in the official WP repository, but would still like it to support automatic updates. Despite the name, it also works with themes.
MIT License
2.22k stars 403 forks source link

How to update Theme AND Plugin? #503

Open fredchandler opened 1 year ago

fredchandler commented 1 year ago

Hello, using the code

require get_template_directory() . '/inc/plugin-update-checker/plugin-update-checker.php'; $myUpdateChecker = Puc_v4_Factory::buildUpdateChecker( 'exampleurl.com/theme.json', __FILE__, //Full path to the main plugin file or functions.php. 'slug' );

works ok to update themes from an external resource.

But i want to know how to, or what is the correct code to get updates from theme AND plugins (both hosted on external urls). if i add another url below the first json url file with "plugin.json" i get an obvious error.

thanks

YahnisElsts commented 1 year ago

Technically, you can just make a copy of the $myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(...) code, change the variable name and the arguments, and put it below the theme update checker code.

I think the code that updates a plugin usually goes in the plugin and not in the theme, but you can put it in the theme if you want. Just make sure to provide the correct path to the main plugin file - __FILE__ won't work if the code isn't actually in the plugin file.

YahnisElsts commented 1 year ago

@AhmadRaza9 It looks like your comment is not related to this issue. If you have a separate problem, please create a new issue.

(And, to save you some time: make sure that your plugin directory is not open in some application - console, IDE, Git/SVN software - while you're trying to install an update.)