Closed gwuluo closed 1 year ago
No, it doesn't have to be in functions.php
. You can put the code that initializes the update checker in a different file, but you need to be careful to pass the correct file path to the buildUpdateChecker()
method. The second argument should be the full path to a file in your theme's main directory, like functions.php
or style.css
. If the code is in functions.php
you can just use the __FILE__
constant, but in a different file, you'll need another solution.
How you do that is up to you. For example, you could define a new constant in your functions.php
, like
defined('MY_THEME_FUNCTIONS_PHP_FILE', __FILE__);
... and then pass that to the update checker:
$myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
'http://example.com/path/to/details.json',
MY_THEME_FUNCTIONS_PHP_FILE,
'unique-plugin-or-theme-slug'
);
Thank you very much.
Does it have to be in functions.php? It is not executed in other php, how should I write it? Thank you