admin管理员组文章数量:1130349
I think this best way to prevent direct access..
<?php if (!defined('ABSPATH')) { exit; }?>
i have used this on all my php files..can it create problems? any files on WordPress theme i should not use it?
I think this best way to prevent direct access..
<?php if (!defined('ABSPATH')) { exit; }?>
i have used this on all my php files..can it create problems? any files on WordPress theme i should not use it?
Share Improve this question asked Nov 16, 2018 at 11:12 user145078user145078 1- See wordpress.stackexchange/questions/62999/… – fuxia ♦ Commented Nov 16, 2018 at 13:50
1 Answer
Reset to default 8The point of that code is to prevent any PHP inside the file from being executed if the file is accessed directly outside a WordPress context. ABSPATH is defined by WordPress, so if it's missing when the file is accessed you can tell that it's not running in a WordPress context.
So the only place you wouldn't use it is in any file that you did need to access directly. There probably shouldn't be any such files in a WordPress theme or plugin. The most common example might be a file for handling AJAX requests, but in WordPress you should be using admin-ajax.php or the REST API for that sort of thing.
I think this best way to prevent direct access..
<?php if (!defined('ABSPATH')) { exit; }?>
i have used this on all my php files..can it create problems? any files on WordPress theme i should not use it?
I think this best way to prevent direct access..
<?php if (!defined('ABSPATH')) { exit; }?>
i have used this on all my php files..can it create problems? any files on WordPress theme i should not use it?
Share Improve this question asked Nov 16, 2018 at 11:12 user145078user145078 1- See wordpress.stackexchange/questions/62999/… – fuxia ♦ Commented Nov 16, 2018 at 13:50
1 Answer
Reset to default 8The point of that code is to prevent any PHP inside the file from being executed if the file is accessed directly outside a WordPress context. ABSPATH is defined by WordPress, so if it's missing when the file is accessed you can tell that it's not running in a WordPress context.
So the only place you wouldn't use it is in any file that you did need to access directly. There probably shouldn't be any such files in a WordPress theme or plugin. The most common example might be a file for handling AJAX requests, but in WordPress you should be using admin-ajax.php or the REST API for that sort of thing.
本文标签: theme developmentWhere i should not use if (defined(39ABSPATH39))exit
版权声明:本文标题:theme development - Where i should not use if (!defined('ABSPATH')) { exit; }? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749175116a2327664.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论