我尝试应用一个检查,以确定插件是否处于非活动状态或根本没有安装在插件目录中。当我进行测试时,我会检查是否安装了一个插件,但如屏幕截图所示,该插件未激活。
检查非活动部件是否工作正常:$isinactive = is_plugin_inactive( \'advanced-custom-fields/acf.php\' );
var_dump( $isinactive );
在检查插件是否已实际安装并且是否存在于插件目录中时,不会。首先,我生成主插件文件的路径:$pathpluginurl = plugins_url( \'advanced-custom-fields/acf.php\' );
var_dump($pathpluginurl);
然后检查该文件是否存在:$isinstalled = file_exists( $pathpluginurl );
var_dump($isinstalled);
然后检查特定文件是否不存在:if ( ! file_exists( $pathpluginurl ) ) {
echo "File does not exist";
} else {
echo "File exists";
}
输出:true //true for that the plugin is not active
http://mysandbox.test/wp-content/plugins/advanced-custom-fields/acf.php
false // false for that the acf.php file actually exists
file not exists
我不明白为什么file\\u exists没有陈述事实,相反地说插件不存在?