wordpress - Wordpress plugin ABSPATH or die
问题描述
wordpress plugin .php file has the first line as
defined('ABSPATH') or die("Cannot access pages directly.");
i understand that this line protects php file and prevents direct access.
what to do if i want to access the file or activate it in a wordpress website. Thanks
解决方案
Try:
include_once plugin_dir_path( __FILE__ ) . 'my-plugin-dir/my-filename.php';
Where my-plugin-dir is the server directory of your plugin, and my-filename.php is the file you want to load.
(I've used include_once
in my example, but obviously if you need to load this file more than once use include
instead)
推荐阅读
- uwp - Xbox Live Creators Program 发布配置。发布失败
- javascript - 如何在 vanilla Javascript 中将对象转换为具有正确数据类型的数组?
- php - MySQL 中的重复记录。EXISTS 检查相同的数据不能正常工作?
- javascript - 在数组中查找单个元素的出现
- android - 如何从android中的strings.xml获取整数值
- c++ - 如何在 C++ 中定义一个将被另一个短语替换的短语?
- html - Vue - html'select'标签上的v-for正在创建多个下拉框而不是一个
- ios - 当每个部分中的行数不同时,如何获取 numberOfRows 的计数?
- r - 如何在R中找到分类列的平均值
- arrays - 在二维 numpy 数组中插入值