コメントの追加・削除・文言修正 http://wpdocs.osdn.jp/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/comment_form https://core.trac.wordpress.org/browser/tags/4.7.2/src/wp-includes/comment-template.php
add_action( 'wp_list_comments_args', array( $this, 'comment_custom_display' ) );
function comment_custom_display( $r ) {
$args = array(
'callback' => array( $this, 'custom_comment' ),
);
$r = wp_parse_args( $args, $r );
return $r;
}
// コメント表示用のカスタム
function custom_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
<div id="comment-<?php comment_ID(); ?>">
<div class="cf">
<div class="comment-author vcard img">
<?php echo get_avatar( $comment, 38 ); ?>
</div>
<div class="txt">
<?php comment_text(); ?>
</div>
</div>
<div class="plof">
<span class="penName"><?php comment_author_link(); ?></span><span class="time">投稿日:<?php comment_date('Y/m/d(D)') ?></span>
</div>
</div>
<?php
}
add_filter( 'comment_form_fields', function shift_comment_form );
function shift_comment_form( $fields ) {
//一度削除してから、セットすることで順番が最後になる
$comment_field = $fields ['comment'];
unset( $fields ['comment'] );
$fields ['comment'] = $comment_field;
return $fields;
}
add_filter( 'comment_form_defaults', array( $this, 'custom_comment_form') );
function custom_comment_form( $args ) {
//文言修正
$args = array (
'title_reply' => '<p class="commentTit">この記事に関するコメント</p>',
'label_submit' => '送信する',
'comment_notes_before' => '',
'comment_field' => '<p class="comment-form-comment"><textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" aria-required="true" required="required"></textarea></p>',
);
return $args;
}
add_filter( "comment_form_default_fields", "comment_default_remove");
function comment_default_remove( $fields ){
// 不要フォームの削除
$fields['author'] = '';
$fields['url'] = '';
$fields['email'] = '';
}