當我嘗試激活我寫的一個插件時,wordpres會嘗試激活錯誤的插件,我說我去Plugins->Installed Plugins
並激活,wordpress會返回'anspress'插件無法提供的錯誤消息被發現。Wordpress試圖激活錯誤的插件
我的插件名稱爲「Academy」,文件夾名稱爲「academy」,插件文件名爲「academy.php」。
academy.php內容:
<?php
/**
* @package Academy
*/
/*
Plugin Name: Academy
Description: Academy features
Version: 0.1
Author: Victor Aurélio Santos
Text Domain: academy
*/
/* is_plugin_active */
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
define ('ACADEMY_INCLUDE', plugin_dir_path(__FILE__) . '/include');
define ('ACADEMY_TEMAPLE', ACADEMY_INCLUDE . '/templates');
global $academy_err; $academy_err = array();
$plugin_dependencies = array('woocommerce' => false,
'anspress' => false);
/* Dependencies check */
foreach ($plugin_dependencies as $plugin => &$enabled) {
if (! $enabled = is_plugin_active("{$plugin}/{$plugin}.php")) {
$academy_err[] = "The {$plugin} plugin isn't installed and/or activated.";
}
}
/* Check current theme, if not 'Academy' don't load files that depends... */
if ("Academy" == wp_get_theme()->Name) {
include ACADEMY_INCLUDE . '/buddypress/bp-loader.php';
include ACADEMY_INCLUDE . '/news-feed.php';
} else {
$academy_err[] = "Current theme isn't \"Academy\" not loading NewsFeed...";
}
/* Check for woocommerce */
if ($plugin_dependencies['woocommerce'] && $plugin_dependencies['anspress']){
include ACADEMY_INCLUDE . '/anspress-woocommerce.php';
}
include (ACADEMY_INCLUDE . '/settings.php');
function academy_admin_notices() {
global $academy_err;
foreach ($academy_err as $err) {
?>
<div class="update-nag">
<p>Academy Error: <?php echo $err; ?></p>
</div>
<?php
}
}
add_action('admin_notices', 'academy_admin_notices');
function academy_init() {
$plugin_dir = basename(dirname(__FILE__)) . '/languages';
load_plugin_textdomain('academy', false, $plugin_dir);
}
add_action('plugins_loaded', 'academy_init');
function academy_plugin_action_links ($links, $file) {
static $this_plugin;
if (!$this_plugin) {
$this_plugin = plugin_basename(__FILE__);
}
if ($file == $this_plugin) {
$settings_link = '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php? page=academy-settings">' . __('Settings', 'academy') . '</a>';
array_unshift($links, $settings_link);
}
return $links;
}
add_filter('plugin_action_links', 'academy_plugin_action_links', 10, 2);
我認爲這是錯誤的東西與我的插件,卻找不到什麼。
is_plugin_active功能 –
@brasofilo法典,http://codex.wordpress.org/Function_Reference/is_plugin_active#Usage –
@brasofilo沒關係,就算我註釋掉這包括使用「is_plugin_active」線, WordPress繼續嘗試啓用錯誤的插件。 –