• 售前

  • 售后

热门帖子
入门百科

wordpress复兴批评笔墨的修改方法

[复制链接]
luly靓 显示全部楼层 发表于 2021-8-15 19:57:02 |阅读模式 打印 上一主题 下一主题
  WordPress主题教程之修改wordpress回复批评文字方法,首选必要建立个自界说的批评模板,然后通过调用此批评函数来实现自界说,通过以下代码可以实现修改回复文字:
  1. <span class="sh_symbol"><?</span>php
  2. $defaults <span class="sh_symbol">=</span> <span style="FONT-STYLE: normal; COLOR: rgb(0,0,0); FONT-WEIGHT: bold" class="sh_function">array</span><span class="sh_symbol">(</span><span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'add_below'</span> <span class="sh_symbol">=></span> <span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'comment'</span><span class="sh_symbol">,</span> <span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'respond_id'</span> <span class="sh_symbol">=></span> <span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'respond'</span><span class="sh_symbol">,</span> <span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'reply_text'</span> <span class="sh_symbol">=></span> <span style="FONT-STYLE: normal; COLOR: rgb(0,0,0); FONT-WEIGHT: bold" class="sh_function">__</span><span class="sh_symbol">(</span><span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'Reply'</span><span class="sh_symbol">),</span>
  3. <span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'login_text'</span> <span class="sh_symbol">=></span> <span style="FONT-STYLE: normal; COLOR: rgb(0,0,0); FONT-WEIGHT: bold" class="sh_function">__</span><span class="sh_symbol">(</span><span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'Reply'</span><span class="sh_symbol">),</span> <span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'depth'</span> <span class="sh_symbol">=></span> <span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_number">0</span><span class="sh_symbol">,</span> <span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'before'</span> <span class="sh_symbol">=></span> <span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">''</span><span class="sh_symbol">,</span> <span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'after'</span> <span class="sh_symbol">=></span> <span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">''</span><span class="sh_symbol">);</span>
  4. <span style="FONT-STYLE: normal; COLOR: rgb(0,0,0); FONT-WEIGHT: bold" class="sh_function">comment_reply_link</span><span class="sh_symbol">(</span><span style="FONT-STYLE: normal; COLOR: rgb(0,0,0); FONT-WEIGHT: bold" class="sh_function">array_merge</span><span class="sh_symbol">(</span> $defaults<span class="sh_symbol">,</span> <span style="FONT-STYLE: normal; COLOR: rgb(0,0,0); FONT-WEIGHT: bold" class="sh_function">array</span><span class="sh_symbol">(</span><span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'depth'</span> <span class="sh_symbol">=></span> $depth<span class="sh_symbol">,</span> <span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'max_depth'</span> <span class="sh_symbol">=></span> $args<span class="sh_symbol">[</span><span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'max_depth'</span><span class="sh_symbol">])))</span> <span class="sh_symbol">?></span>
复制代码
  你可以将 Reply 修改成你盼望的文字。
  1. $defaults <span class="sh_symbol">=</span> <span style="FONT-STYLE: normal; COLOR: rgb(0,0,0); FONT-WEIGHT: bold" class="sh_function">array</span><span class="sh_symbol">(</span>‘add_below’ <span class="sh_symbol">=></span> ‘comment’<span class="sh_symbol">,</span> ‘respond_id’ <span class="sh_symbol">=></span> ‘respond’<span class="sh_symbol">,</span> ‘reply_text’ <span class="sh_symbol">=></span> <span style="FONT-STYLE: normal; COLOR: rgb(0,0,0); FONT-WEIGHT: bold" class="sh_function">__</span><span class="sh_symbol">(</span>‘Reply’<span class="sh_symbol">)</span>
复制代码
  这行是默认的回复批评。
  1. ‘login_text’ <span class="sh_symbol">=></span> <span style="FONT-STYLE: normal; COLOR: rgb(0,0,0); FONT-WEIGHT: bold" class="sh_function">__</span><span class="sh_symbol">(</span>‘Reply’<span class="sh_symbol">),</span> ‘depth’ <span class="sh_symbol">=></span> <span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_number">0</span><span class="sh_symbol">,</span> ‘before’ <span class="sh_symbol">=></span> ”<span class="sh_symbol">,</span> ‘after’ <span class="sh_symbol">=></span> ”<span class="sh_symbol">);</span>
复制代码
  这行是登岸后批评。
  1. <span style="FONT-STYLE: normal; COLOR: rgb(0,0,0); FONT-WEIGHT: bold" class="sh_function">comment_reply_link</span><span class="sh_symbol">(</span><span style="FONT-STYLE: normal; COLOR: rgb(0,0,0); FONT-WEIGHT: bold" class="sh_function">array_merge</span><span class="sh_symbol">(</span> $defaults<span class="sh_symbol">,</span> <span style="FONT-STYLE: normal; COLOR: rgb(0,0,0); FONT-WEIGHT: bold" class="sh_function">array</span><span class="sh_symbol">(</span>‘depth’ <span class="sh_symbol">=></span> $depth<span class="sh_symbol">,</span> ‘max_depth’ <span class="sh_symbol">=></span> $args<span class="sh_symbol">[</span><span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'max_depth'</span><span class="sh_symbol">])))</span>
复制代码
  这行是批评链接。
 将以上代码放在批评 loop 内既可利用,下面是完整的 custom_comment.php 函数文件:
  1. <?php[color=#A52A2A]if[/color] (![color=#000000][b]function_exists[/b][/color]([color=#FF00FF]"custom_comment"[/color])) {[color=#A52A2A]function[/color] [color=#000000][b]custom_comment[/b][/color]($comment, $args, $depth) {$GLOBALS[[color=#FF00FF]'comment'[/color]] = $comment; ?><li <?php [color=#000000][b]comment_class[/b][/color](); ?>><a name=[color=#FF00FF]"comment-<?php comment_ID() ?>"[/color]></a><?php [color=#A52A2A]if[/color]([color=#000000][b]get_comment_type[/b][/color]() == [color=#FF00FF]"comment"[/color]){ ?><?php [color=#000000][b]the_commenter_avatar[/b][/color]($args) ?><?php } ?><span class="sh_symbol"><?</span>php
  2. $defaults <span class="sh_symbol">=</span> <span style="FONT-STYLE: normal; COLOR: rgb(0,0,0); FONT-WEIGHT: bold" class="sh_function">array</span><span class="sh_symbol">(</span><span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'add_below'</span> <span class="sh_symbol">=></span> <span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'comment'</span><span class="sh_symbol">,</span> <span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'respond_id'</span> <span class="sh_symbol">=></span> <span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'respond'</span><span class="sh_symbol">,</span> <span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'reply_text'</span> <span class="sh_symbol">=></span> <span style="FONT-STYLE: normal; COLOR: rgb(0,0,0); FONT-WEIGHT: bold" class="sh_function">__</span><span class="sh_symbol">(</span><span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'Reply'</span><span class="sh_symbol">),</span>
  3. <span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'login_text'</span> <span class="sh_symbol">=></span> <span style="FONT-STYLE: normal; COLOR: rgb(0,0,0); FONT-WEIGHT: bold" class="sh_function">__</span><span class="sh_symbol">(</span><span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'Reply'</span><span class="sh_symbol">),</span> <span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'depth'</span> <span class="sh_symbol">=></span> <span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_number">0</span><span class="sh_symbol">,</span> <span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'before'</span> <span class="sh_symbol">=></span> <span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">''</span><span class="sh_symbol">,</span> <span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'after'</span> <span class="sh_symbol">=></span> <span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">''</span><span class="sh_symbol">);</span>
  4. <span style="FONT-STYLE: normal; COLOR: rgb(0,0,0); FONT-WEIGHT: bold" class="sh_function">comment_reply_link</span><span class="sh_symbol">(</span><span style="FONT-STYLE: normal; COLOR: rgb(0,0,0); FONT-WEIGHT: bold" class="sh_function">array_merge</span><span class="sh_symbol">(</span> $defaults<span class="sh_symbol">,</span> <span style="FONT-STYLE: normal; COLOR: rgb(0,0,0); FONT-WEIGHT: bold" class="sh_function">array</span><span class="sh_symbol">(</span><span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'depth'</span> <span class="sh_symbol">=></span> $depth<span class="sh_symbol">,</span> <span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'max_depth'</span> <span class="sh_symbol">=></span> $args<span class="sh_symbol">[</span><span style="FONT-STYLE: normal; COLOR: rgb(255,0,255); FONT-WEIGHT: normal" class="sh_string">'max_depth'</span><span class="sh_symbol">])))</span> <span class="sh_symbol">?></span><?php [color=#000000][b]the_commenter_link[/b][/color]() ?><?php echo [color=#000000][b]get_comment_date[/b][/color]([color=#000000][b]get_option[/b][/color]( [color=#FF00FF]'date_format'[/color] )) ?> <?php [color=#000000][b]_e[/b][/color]([color=#FF00FF]'at'[/color], [color=#FF00FF]'jintu'[/color]); ?> <?php echo [color=#000000][b]get_comment_time[/b][/color]([color=#000000][b]get_option[/b][/color]( [color=#FF00FF]'time_format'[/color] )); ?><?php [color=#000000][b]edit_comment_link[/b][/color]([color=#000000][b]__[/b][/color]([color=#FF00FF]'Edit'[/color], [color=#FF00FF]'jintu'[/color]), [color=#FF00FF]''[/color], [color=#FF00FF]''[/color]); ?><?php [color=#000000][b]comment_text[/b][/color]() ?><?php [color=#A52A2A]if[/color] ($comment->comment_approved == [color=#FF00FF]'0'[/color]) { ?><p [color=#A52A2A]class[/color]=[color=#FF00FF]'unapproved'[/color]><?php [color=#000000][b]_e[/b][/color]([color=#FF00FF]'Your comment is awaiting moderation.'[/color], [color=#FF00FF]'jintu'[/color]); ?></p><?php } ?><?php}} ?>
复制代码
  将上面的代码保存到 custom_comment.php 文件, 在functions.php里加载即可,wordpress修改回复文字的方法就这么简单,试试吧。

帖子地址: 

回复

使用道具 举报

分享
推广
火星云矿 | 预约S19Pro,享500抵1000!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

草根技术分享(草根吧)是全球知名中文IT技术交流平台,创建于2021年,包含原创博客、精品问答、职业培训、技术社区、资源下载等产品服务,提供原创、优质、完整内容的专业IT技术开发社区。
  • 官方手机版

  • 微信公众号

  • 商务合作