get_extended()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
get_extended( string $post ): string[]
Описание
После второго дефиса и перед словом ‘more’ не должно быть пробелов. После слова ‘more’ может быть текст или пробел(ы), но они не используются.
Возвращаемый массив содержит ключи ‘main’, ‘extended’ и ‘more_text’. Ключ ‘main’ содержит текст до . Ключ ‘extended’ содержит содержимое после комментария . Ключ ‘more_text’ содержит пользовательский текст «Читать далее».
Оригинал (английский)
There should not be any space after the second dash and before the word ‘more’. There can be text or space(s) after the word ‘more’, but won’t be referenced.
The returned array has ‘main’, ‘extended’, and ‘more_text’ keys. Main has the text before the <!--more-->. The ‘extended’ key has the content after the <!--more--> comment. The ‘more_text’ key has the custom “Read More” text.
Параметры
$post
string
обязательный
Возвращаемое значение
string[]
Исходный код
wp-includes/post.php:1070
function get_extended( $post ) {
// Match the new style more links.
if ( preg_match( '/<!--more(.*?)?-->/', $post, $matches ) ) {
list($main, $extended) = explode( $matches[0], $post, 2 );
$more_text = $matches[1];
} else {
$main = $post;
$extended = '';
$more_text = '';
}
// Leading and trailing whitespace.
$main = preg_replace( '/^[\s]*(.*)[\s]*$/', '\\1', $main );
$extended = preg_replace( '/^[\s]*(.*)[\s]*$/', '\\1', $extended );
$more_text = preg_replace( '/^[\s]*(.*)[\s]*$/', '\\1', $more_text );
return array(
'main' => $main,
'extended' => $extended,
'more_text' => $more_text,
);
}
История изменений
| Версия | Описание |
|---|---|
| 1.0.0 | Introduced. |

