我正在努力完成一项艰巨的任务。任务是使用可用的WP钩子从Yoast SEO文件中删除echo
。删除函数的回显 - WordPress
类frontend.php
public function head() {
global $wp_query;
$old_wp_query = null;
if (! $wp_query->is_main_query()) {
$old_wp_query = $wp_query;
wp_reset_query();
}
/**
* Action: 'wpseo_head' - Allow other plugins to output inside the Yoast SEO section of the head section.
*/
do_action('wpseo_head');
echo '<!--/', $this->head_product_name(), ". -->\n\n"; // <-- remove this
if (! empty($old_wp_query)) {
$GLOBALS['wp_query'] = $old_wp_query;
unset($old_wp_query);
}
return;
}
有没有办法超越此功能,并使用现有的WP钩去掉echo
?还是有更好的方法来做到这一点?
非常感谢。
鉴于echo命令不在条件执行路径中,显然没有办法调用“hook”可以避免它被调用(除了“hook”完全替换了head()函数共)。 – eggyal
@eggyal你知道用我自己的方式替换这个函数吗? – Mitch
你能解释一下如何消除这条线让你的生活变得更好吗?可能有其他选择。 – RST