我会用str_replace()
处理“伪”短代码。类似这样:
$body = sprintf(\'Hey {{username}}, your awesome post has been published!
See <%s>\', get_permalink($post) );
// Add replacement values to the array as necessary.
$old = array( \'{{username}}\' );
$new = array( esc_html($user->display_name) );
$body = str_replace( $old, $new, $body );
// Now send to the post author.
wp_mail($user->user_email, \'Your post has been published!\', $body);
我只是从你开始的工作开始。我想你应该在这之前做点什么
$user
对象此外,我还为
str_replace()
作为数组,因此可以根据需要添加到其中(而不是多次运行)。