Reputation: 1313
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';
}
Upvotes: 0
Views: 1684
Reputation: 19308
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/';
Upvotes: 2