Closed masoudarvishi closed 4 years ago
Judging by the file name in the error message, your code might be inside the plugin-update-checker.php
file. Is that true? If yes, then you will need to either move the code to a different file that's in the theme's root directory (e.g. functions.php
) or replace __FILE__
with the full path to the theme directory.
For themes, the second argument passed to buildUpdateChecker()
must be the full path to the theme directory (or a file that's immediately inside that directory), so the __FILE__
constant will only work if the code that calls buildUpdateChecker()
is in functions.php
or another top-level file.
Thanks. Yes the file path is correct. Can you provide me with a sample code? I did not catch
I replaced this code __FILE__
use get_template_directory()
but not work.
What happens when you use get_template_directory()
? Do you still get the exact same error message or something different?
Can you provide me with a sample code?
Any sample code that I could provide would look pretty much the same as your current code except for the function arguments. Unfortunately, I can't provide the correct arguments because they will be different for every theme.
No no error is given. You fixed the error and I put the codes in a separate file.
I put the code in the theme function file, it worked fine. But I put the code in another file, it does not work and does not give any errors. I think the problem is from __FILE__
I do not know what to put in place of this __FILE__
i use code in funtctions.php theme:
if (!class_exists('Puc_v4_Factory')) {
require_once(get_template_directory(). 'plugin-update-checker/plugin-update-checker.php' );
}
$UpdateChecker = Puc_v4_Factory::buildUpdateChecker(
'http://myserver.co/?action=get_metadata&slug=tia20',
FILE,
'tia20'
);
is worked!
But I want to put this code in another file.
I put the above code in this file. I created this file myself. I put this file in the theme function
if (!class_exists('Puc_v4_Factory')) {
require_once(get_template_directory(). 'plugin-update-checker/plugin-update-checker-url.php' );
}
have put this code in the file (plugin-update-checker-url.php) as well:
if (!class_exists('Puc_v4_Factory')) {
require_once(get_template_directory(). 'plugin-update-checker/plugin-update-checker.php' );
}
$UpdateChecker = Puc_v4_Factory::buildUpdateChecker(
'http://myserver.co/?action=get_metadata&slug=tia20',
FILE,
'tia20'
);
This may sound like a silly question, but if there is no error when you use get_template_directory()
instead of __FILE__
, how do you know that the code isn't working?
One way to work around the problem might be to define a new file name constant in functions.php
and then use that in your other file. For example, do this in functions.php
:
define('MY_THEME_FUNCTIONS_PHP', __FILE__);
Then use the new constant in plugin-update-checker-url.php
:
$UpdateChecker = Puc_v4_Factory::buildUpdateChecker(
'http://myserver.co/?action=get_metadata&slug=tia20',
MY_THEME_FUNCTIONS_PHP,
'tia20'
);
Of course, MY_THEME_FUNCTIONS_PHP
is just an example name and I would recommend replacing it with something more unique.
thank you very much. The problem was solved. thank you.
How can I hide the download link? After the update operation, by clicking on the update details, the download link will be displayed. This is very bad!
i use md5, but not work.
link http://myserver.co/?action=get_metadata&slug=tia20 convert to bcb00107d4d5c64e2364cb8dcb1fa9a9.
https://www.md5hashgenerator.com/
After this, the update will no longer be displayed
Do you want the user to be able to install the update? Then their server must have the update link (or at least have a way to generate the link, which is effectively the same as having the link). And if the user's server has the link then the user can get the link, too.
If you want to prevent people from reusing download links, you could modify the update server to require a license key and/or provide time-limited links. However, all of that is beyond the scope of this discussion.
I do not want the user to be able to see the link during the update! I want the link to be hidden
I don't know how to do that, at least not off the top of my head. Also, I wouldn't recommend spending too much time on that because it would be pretty useless from a security perspective - a skilled user would be able to get the link anyway.
tnx.
All right then, I'll close this now.
Hello.
i use this code:
if (!class_exists('Puc_v4_Factory')) { require_once(get_template_directory(). 'plugin-update-checker/plugin-update-checker.php' ); } $UpdateChecker = Puc_v4_Factory::buildUpdateChecker( 'http://myserver.co/?action=get_metadata&slug=tia20', FILE, 'tia20' );
but when refresh mywebsite (in localhost) showing this error:
RuntimeException: The update checker cannot determine if "C:/wamp64/www/myweb/wp-content/themes/tia20/plugin-update-checker/plugin-update-checker.php" is a plugin or a theme. This is a bug. Please contact the PUC developer. in C:\wamp64\www\myweb\wp-content\themes\tia20\plugin-update-checker\Puc\v4p10\Factory.php on line 80
I easily provided this feature for plugins. But I have this problem in themes!