我读到有两种方法可以在Wordpress主题上集成插件。
我认为第一种方法是最好的;但我不知道怎么做。。。
After copying the plugin to the plugin directory of Wordpress... How do I enable it? Do you know another way to do this?
然后我揭露我所做的事,好让你们证明我的想法是否正确:第一种方法:将我的插件复制到wp内容/插件activate_plugin 安装它
function recurse_copy($src,$dst) {
$dir = opendir($src);
@mkdir($dst);
while(false !== ( $file = readdir($dir)) ) {
if (( $file != \'.\' ) && ( $file != \'..\' )) {
if ( is_dir($src . \'/\' . $file) ) {
recurse_copy($src . \'/\' . $file,$dst . \'/\' . $file);
} else {
copy($src . \'/\' . $file,$dst . \'/\' . $file);
}
}
}
closedir($dir);
}
// I copy my plugin to wp-content/plugins
recurse_copy($path."/plugins/myplugin_Directory", WP_PLUGIN_DIR . "/myplugin_Directory");
第二种方法:使用我的插件代替wp内容插件中的插件路径)更改为主题目录中资源的所有依赖项Example for the second method: (把这个放进去functions.php
)add_action(\'after_setup_theme\', \'load_MyPlugin\');
function load_MyPlugin() {
if (!class_exists(\'MyPluginClass\')) {
include_once(get_template_directory_uri() . \'/plugins/myplugin_Directory/index.php\');
}
}