wp include/shortcode中有一个get\\u shortcode\\u regex()函数。php。do\\u shortcode()和其他人使用它。采用regex表达式相当容易。
global $post;
$tags = array();
$pattern = \'(.?)\\[(translate)\\b\\s+(.*?)(?:(\\/))?\\](?:(.+?)\\[\\/translate\\])?(.?)\';
$pattern = "/$pattern/s";
preg_match_all($pattern, $post->post_content, &$tags, PREG_SET_ORDER);
foreach ($tags as $t ){
// iterate over tags...
}