
如何在WordPress中使用Bootstrap图标?
get_url_in_content ( $content )
get_url_in_content: 这个函数检索出现在文章内容中的第一个URL。它接收一个文章ID作为参数,并以字符串形式返回URL。
从传来的内容中提取并返回第一个URL。
function get_url_in_content( $content ) { if ( empty( $content ) ) { return false; } if ( preg_match( '/<as[^>]*?href=(['"])(.+?)1/is', $content, $matches ) ) { return sanitize_url( $matches[2] ); } return false; }