2025-02-22
「最新のコメント」をリニューアルしました
久しぶりにサイトのPHPを8.2.22に上げたところ、これまで使用していたプラグイン「WP-RecentComments」がエラーを吐いて動かなくなってしまいました。このプラグイン、デザインも機能も非常に優れていたので愛用していたのですが、もう12年くらい更新されてなかったみたいです。これも時代か…
そこで、「Better Recent Comments」に変更しました。ただしこのプラグインは日本語化されておらず、見た目も変わってしまったので、多少いじって以前のデザインに近づけています。備忘のために変更点をメモしておきます。
変更前
「プラグインファイルエディター」 > 「Better Recent Comments」 > src > Util.php
if ( $avatar ) { $format .= '{avatar} '; } if ( $post_link ) { /* translators: comments widget: 1: comment author, 2: post link */ $format .= sprintf( _x( '%1$s on %2$s', 'recent comment', 'better-recent-comments' ), '{author}', '{post}' ); } else { $format .= '{author}'; } if ( $comment ) { $format .= ': “{comment}”'; } if ( $date ) { $format .= ' {date}'; }
変更後
36・41行目を修正。
if ( $avatar ) { $format .= '{avatar} '; } if ( $post_link ) { /* translators: comments widget: 1: comment author, 2: post link */ $format .= sprintf( _x( '<strong>%1$s</strong> : %2$s', 'recent comment', 'better-recent-comments' ), '{author}', '{post}' ); } else { $format .= '{author}'; } if ( $comment ) { $format .= '<br />{comment}'; } if ( $date ) { $format .= ' {date}'; }
>>至宝を壊すとどうなるのかについての検証が全くないのが気になります まあヴァ…