2013-01-14 12:45
浏览 383


I use a Private Message script where it adds a Re: to the message subject upon every reply. Unfortunately, if there are more than one reply to the same message, it adds another Re:, so by the time a few PMs have been exchanged, it looks like this:

Re: Re: Re: Re: Re: Re: Re: Re: Hello World!

Here are the relevant parts of the script that does this:

                    | <a class="reply"
                    href="<?php echo wp_nonce_url( "?page=rwpm_send&recipient=$msg->sender&id=$msg->id&subject=Re: " . stripcslashes( $msg->subject ), 'rwpm-reply_inbox_msg_' . $msg->id ); ?>"><?php _e( 'Reply', 'pm4wp' ); ?></a>

So I want to adjust the script so that it only adds one Re: if there is a reply. How do I do that? I am guessing maybe an IF statement checking if there is already a Re: there or not...

图片转代码服务由CSDN问答提供 功能建议

我使用私人消息脚本,在其中添加 Re:到消息主题 每一个答复。 不幸的是,如果对同一条消息有多个回复,它会添加另一个 Re:,所以当交换几个PM时,它看起来像这样: \ n

Re:Re:Re:Re:Re:Re:Re:Re:Hello World!

以下是脚本的相关部分 这样做:

  |  &lt; a class =“reply”
 href =“&lt;?php echo wp_nonce_url(”?page = rwpm_send&amp; recipient = $ msg-&gt; sender&amp; id = $ msg-&gt; id&amp; subject = Re:“。  stripcslashes($ msg-&gt; subject),'rwpm-reply_inbox_msg_'。$ msg-&gt; id);?&gt;“&gt;&lt;?php _e('Reply','pm4wp');  ?&gt;&lt; / a&gt; 

所以我想调整脚本以便它只添加一个 Re: 如果有回复。 我怎么做? 我猜可能是一个IF语句,检查是否已经存在 Re: ......

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongshou1856 2013-01-14 12:50

    So, add the "Re: " only if there is no:

    | <a class="reply" href="<?php echo wp_nonce_url( "?page=rwpm_send&recipient=$msg->sender&id=$msg->id&subject=".(strpos($msg->subject, "Re:") === false ? "Re: " : ""). stripcslashes( $msg->subject ), 'rwpm-reply_inbox_msg_' . $msg->id ); ?>"><?php _e( 'Reply', 'pm4wp' ); ?></a>

    And, when it only should stay on the beginning:

       | <a class="reply" href="<?php echo wp_nonce_url( "?page=rwpm_send&recipient=$msg->sender&id=$msg->id&subject=".(substr($msg->subject, 0, 3) != "Re:" ? "Re: " : ""). stripcslashes( $msg->subject ), 'rwpm-reply_inbox_msg_' . $msg->id ); ?>"><?php _e( 'Reply', 'pm4wp' ); ?></a>
    解决 无用
    打赏 举报
  • douju1997 2013-01-14 12:50

    ow about a simple regexp?

    $replysubject = preg_replace('/^(Re: )*/', 'Re: ', stripcslashes( $subject ));

    This will output a string with just one 'Re: ' at the beginning, regardless of how many of them are in the input string.

    In your case:

    href="<?php echo wp_nonce_url( "?page=rwpm_send&recipient=$msg->sender&id=$msg->id&subject=" . $replysubject, 'rwpm-reply_inbox_msg_' . $msg->id ); ?>"

    解决 无用
    打赏 举报

相关推荐 更多相似问题