Answers:
您可以尝试使用comment_form_defaults
过滤器对其进行修改:
/**
* Modify the "must_log_in" string of the comment form.
*
* @see http://wordpress.stackexchange.com/a/170492/26350
*/
add_filter( 'comment_form_defaults', function( $fields ) {
$fields['must_log_in'] = sprintf(
__( '<p class="must-log-in">
You must <a href="%s">Register</a> or
<a href="%s">Login</a> to post a comment.</p>'
),
wp_registration_url(),
wp_login_url( apply_filters( 'the_permalink', get_permalink() ) )
);
return $fields;
});
我们在使用wp_registration_url()
和wp_login_url()
核心功能。
ps:法典中似乎缺少有关过滤器的信息comment_form_defaults
。