wp_embed_handler_audio

函数
wp_embed_handler_audio ( $matches, $attr, $url, $rawattr )
参数
  • (array) $matches The RegEx matches from the provided regex when calling wp_embed_register_handler().
    Required:
  • (array) $attr Embed attributes.
    Required:
  • (string) $url The original URL that was matched by the regex.
    Required:
  • (array) $rawattr The original unmodified attributes.
    Required:
返回值
  • (string) The embed HTML.
定义位置
相关方法
wp_embed_handler_videowp_embed_handler_youtubewp_embed_handler_googlevideowp_embed_register_handlerwp_embed_defaults
引入
3.6.0
弃用
-

wp_embed_handler_audio: 这个函数是一个回调函数,用于处理WordPress中的音频嵌入: 当用户在文章或页面中嵌入一个音频文件时,这个函数被调用来处理嵌入代码。

音频嵌入处理回调。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_embed_handler_audio( $matches, $attr, $url, $rawattr ) {
$audio = sprintf( '<a class="wp-embedded-audio" href="https://www.wbolt.com/go?_=92cfa6365faHR0cDovLyZxdW90OyVzJnF1b3Q7" rel="noopener noreferrer nofollow" target="_blank">"%s"</a>', esc_url( $url ) );
/**
* Filters the audio embed output.
*
* @since 3.6.0
*
* @param string $audio Audio embed output.
* @param array $attr An array of embed attributes.
* @param string $url The original URL that was matched by the regex.
* @param array $rawattr The original unmodified attributes.
*/
return apply_filters( 'wp_embed_handler_audio', $audio, $attr, $url, $rawattr );
}
function wp_embed_handler_audio( $matches, $attr, $url, $rawattr ) { $audio = sprintf( '<a class="wp-embedded-audio" href="https://www.wbolt.com/go?_=92cfa6365faHR0cDovLyZxdW90OyVzJnF1b3Q7" rel="noopener noreferrer nofollow" target="_blank">"%s"</a>', esc_url( $url ) ); /** * Filters the audio embed output. * * @since 3.6.0 * * @param string $audio Audio embed output. * @param array $attr An array of embed attributes. * @param string $url The original URL that was matched by the regex. * @param array $rawattr The original unmodified attributes. */ return apply_filters( 'wp_embed_handler_audio', $audio, $attr, $url, $rawattr ); }
function wp_embed_handler_audio( $matches, $attr, $url, $rawattr ) {
	$audio = sprintf( '"%s"', esc_url( $url ) );

	/**
	 * Filters the audio embed output.
	 *
	 * @since 3.6.0
	 *
	 * @param string $audio   Audio embed output.
	 * @param array  $attr    An array of embed attributes.
	 * @param string $url     The original URL that was matched by the regex.
	 * @param array  $rawattr The original unmodified attributes.
	 */
	return apply_filters( 'wp_embed_handler_audio', $audio, $attr, $url, $rawattr );
}

常见问题

FAQs
查看更多 >