我正在为其中一个网站使用wordpress 3.9.1。我的反应很慢,大约35秒。我做了调查;发现wp_head
花费了太多时间。此外,我调试;发现wp中的函数包含/插件。php导致了:
function do_action($tag, $arg = \'\') {
global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
if ( ! isset($wp_actions[$tag]) )
$wp_actions[$tag] = 1;
else
++$wp_actions[$tag];
// Do \'all\' actions first
if ( isset($wp_filter[\'all\']) ) {
$wp_current_filter[] = $tag;
$all_args = func_get_args();
_wp_call_all_hook($all_args);
}
if ( !isset($wp_filter[$tag]) ) {
if ( isset($wp_filter[\'all\']) )
array_pop($wp_current_filter);
return;
}
if ( !isset($wp_filter[\'all\']) )
$wp_current_filter[] = $tag;
$args = array();
if ( is_array($arg) && 1 == count($arg) && isset($arg[0]) && is_object($arg[0]) ) // array(&$this)
$args[] =& $arg[0];
else
$args[] = $arg;
for ( $a = 2; $a < func_num_args(); $a++ )
$args[] = func_get_arg($a);
// Sort
if ( !isset( $merged_filters[ $tag ] ) ) {
ksort($wp_filter[$tag]);
$merged_filters[ $tag ] = true;
}
reset( $wp_filter[ $tag ] );
///////////////////// PROBLEM STARTS FROM HERE //////////////////
do {
foreach ( (array) current($wp_filter[$tag]) as $the_ )
if ( !is_null($the_[\'function\']) )
{
call_user_func_array($the_[\'function\'], array_slice($args, 0, (int) $the_[\'accepted_args\']));
}
} while ( next($wp_filter[$tag]) !== false );
////////////////////////// PROBLEM AREA ENDS HERE ///////////////////
array_pop($wp_current_filter);
}
do中存在问题。。而执行循环大约需要30秒。请建议我如何摆脱这种缓慢的反应。