我正在为使用 WordPress 的flickerRSS RU插件的客户工作。但是,当他们尝试在每页上调用多个函数时,会在 error_log 中收到此错误:
PHP Fatal error: Cannot redeclare get_and_delete_option() (previously declared
in .../wp-content/plugins/flickrrss-ru/flickrrssRU.php:21) in
.../wp-content/plugins/flickrrss-ru/flickrrssRU.php on line 21
第一个插件调用是:
get_flickrRSSRU(array(
'set' => '72157624558519886',
'num_items' => 3,
'type' => 'set',
'html' => ' <a href="%flickr_page%" title="%title%"><img src="%image_square%" alt="%title%"/ height="68px" ></a>'));
其次是:
get_flickrRSSRU(array(
'set' => '72157624558519886',
'num_items' => 11,
'type' => 'set',
'html' => ' <a href="%flickr_page%" title="%title%"><img src="%image_square%" alt="%title%"/ height="75" ></a>'));
如果通过 WordPress 加载插件,我不确定为什么这两个调用会尝试再次初始化插件。
我发现正在使用的这个特定功能在插件中是这样的:
$flickrRSSRU = new flickrRSSRU();
add_action( 'admin_menu', array(&$flickrRSSRU, 'setupSettingsPage') );
add_action( 'plugins_loaded', array(&$flickrRSSRU, 'setupWidget') );
register_activation_hook( __FILE__, array( &$flickrRSSRU, 'setupActivation' ));
function get_flickrRSSRU($settings = array()) {
global $flickrRSSRU;
$flickrRSSRU->printGallery($settings);
}