在学习元数据延迟加载时,我遇到these lines of code:
// Don\'t use `wp_list_pluck()` to avoid by-reference manipulation.
$comment_ids = array();
if ( is_array( $comments ) ) {
foreach ( $comments as $comment ) {
if ( $comment instanceof WP_Comment ) {
$comment_ids[] = $comment->comment_ID;
}
}
}
我认为这与this topic 但这里没有参考文献foreach
循环被包装在一个函数中,在这种情况下如何进行引用操作?为了获得最佳实践,我们应该在何时使用wp_list_pluck()
作用