首页 > 解决方案 > 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

标签: wordpressplugins

解决方案


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)


推荐阅读