wp_rel_callback
函数
wp_rel_callback ( $matches, $rel )
- 参数
-
-
(array)
$matches
Single match.- Required: 是
-
(string)
$rel
The rel attribute to add.- Required: 是
-
(array)
- 返回值
-
- (string) HTML A element with the added rel attribute.
- 定义位置
-
-
wp-includes/formatting.php
, line 3133
-
wp-includes/formatting.php
- 引入
- 5.3.0
- 弃用
- –
Callback to add a rel attribute to HTML A element.
Will remove already existing string before adding to prevent invalidating (X)HTML.
function wp_rel_callback( $matches, $rel ) { $text = $matches[1]; $atts = wp_kses_hair( $matches[1], wp_allowed_protocols() ); if ( ! empty( $atts['href'] ) ) { if ( in_array( strtolower( wp_parse_url( $atts['href']['value'], PHP_URL_SCHEME ) ), array( 'http', 'https' ), true ) ) { if ( strtolower( wp_parse_url( $atts['href']['value'], PHP_URL_HOST ) ) === strtolower( wp_parse_url( home_url(), PHP_URL_HOST ) ) ) { return ""; } } } if ( ! empty( $atts['rel'] ) ) { $parts = array_map( 'trim', explode( ' ', $atts['rel']['value'] ) ); $rel_array = array_map( 'trim', explode( ' ', $rel ) ); $parts = array_unique( array_merge( $parts, $rel_array ) ); $rel = implode( ' ', $parts ); unset( $atts['rel'] ); $html = ''; foreach ( $atts as $name => $value ) { if ( isset( $value['vless'] ) && 'y' === $value['vless'] ) { $html .= $name . ' '; } else { $html .= "{$name}="" . esc_attr( $value['value'] ) . '" '; } } $text = trim( $html ); } return "'; }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。