I'm working on a plugin and trying to embed something if the file/folder exists. This perfectly works in php but not within WP. Any help would be appreciated. This code is in the admin area under the plugin's setting page. And yes, I'm sure the path to the folder is correct.
$filename = plugins_url('../admin_side/webmailing/install/', __FILE__);
if (file_exists($filename)) {
echo 'something';
else {
echo 'something else';
}
file_exists
expects a file path but you're passing it a URL.
Change:
$filename = plugins_url('../admin_side/webmailing/install/', __FILE__);
To:
$filename = plugin_dir_path( __FILE__ ) . 'admin_side/webmailing/install/';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.