据我所知,你不能。你需要把插件放在Wordpress定义的相关插件文件夹中,否则WP将无法看到它们。
See here for instructions on manually installing plugins.
EDIT: Ok, so after our comments above I decided to investigate furter, and it turns out that it is actually pretty easy...
把这个放进你的
functions.php
文件和编辑
$my_plugins_folder
根据您的需要,然后(假设您的插件和主题文件夹位于默认位置)它就会工作。在我的网站上测试过,效果很好。你必须做出的唯一承诺是,它们不会按字母顺序排列,所以你需要写一个
usort()
如果您对此感到担忧,请使用函数。
/** Add plugins nested within the theme to the list of plugins in the admin panel */
add_filter(\'all_plugins\', \'add_custom_plugins\');
function add_custom_plugins(){
$plugins = get_plugins();
$my_plugins_folder_name = \'plugins\';
$my_plugins_path = \'../themes/\'.get_template().\'/\'.$my_plugins_folder_name;
$my_plugins_temp = get_plugins(\'/\'.$my_plugins_path);
$my_plugins = array();
if(!empty($my_plugins_temp)) :
foreach($my_plugins_temp as $key => $value) :
$my_plugins[$my_plugins_path.\'/\'.$key] = $value;
endforeach;
endif;
$plugins = array_merge((array)$my_plugins, (array)$plugins);
return $plugins;
}
ANOTHER EDIT: It looks like this may not work yet, as although WP will add the plugin to your list using the above code, it will not activate it due to having to go up a level. 下面是导致整个过程失败的代码-
function validate_file( $file, $allowed_files = \'\' ) {
if ( false !== strpos( $file, \'..\' )) // **!! Code above fails because of this check !!**
return 1;
if ( false !== strpos( $file, \'./\' ))
return 1;
if (!empty ( $allowed_files ) && (!in_array( $file, $allowed_files ) ) )
return 3;
if (\':\' == substr( $file, 1, 1 ))
return 2;
return 0;
}