функция since 1.5.0

rss_enclosure()

Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.

Сигнатура

rss_enclosure()

Описание

Использует глобальный $post, чтобы проверить, требует ли запись пароль и есть ли у пользователя пароль к этой записи. Если нет, функция завершится до вывода.
Также использует функцию get_post_custom() для получения поля метаданных 'enclosure' записи и разбирает значение для вывода вложения(-й). Вложение(-я) состоят из HTML-тега(-ов) enclosure с URI и другими атрибутами.

Оригинал (английский)

Uses the global $post to check whether the post requires a password and if the user has the password for the post. If not then it will return before displaying.

Also uses the function get_post_custom() to get the post’s ‘enclosure’ metadata field and parses the value to display the enclosure(s). The enclosure(s) consist of enclosure HTML tag(s) with a URI and other attributes.

Исходный код

wp-includes/feed.php:475

function rss_enclosure() {
	if ( post_password_required() ) {
		return;
	}

	foreach ( (array) get_post_custom() as $key => $val ) {
		if ( 'enclosure' === $key ) {
			foreach ( (array) $val as $enc ) {
				$enclosure = explode( "\n", $enc );

				if ( count( $enclosure ) < 3 ) {
					continue;
				}

				// Only get the first element, e.g. 'audio/mpeg' from 'audio/mpeg mpga mp2 mp3'.
				$t    = preg_split( '/[ \t]/', trim( $enclosure[2] ) );
				$type = $t[0];

				/**
				 * Filters the RSS enclosure HTML link tag for the current post.
				 *
				 * @since 2.2.0
				 *
				 * @param string $html_link_tag The HTML link tag with a URI and other attributes.
				 */
				echo apply_filters( 'rss_enclosure', '<enclosure url="' . esc_url( trim( $enclosure[0] ) ) . '" length="' . absint( trim( $enclosure[1] ) ) . '" type="' . esc_attr( $type ) . '" />' . "\n" );
			}
		}
	}
}

История изменений

ВерсияОписание
1.5.0 Introduced.

Что будем искать? Например,Продвижение

Этот сайт использует куки-файлы. Оставаясь на сайте, Вы соглашаетесь на их использование. Для получения дополнительной информации, пожалуйста, ознакомьтесь с политикой в отношении персональных данных.