WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Получай пассивный доход от сайта с помощью браузерных PUSH уведомлений
функция не описана

wp_force_plain_post_permalink() WP 5.7.0

Determine whether post should always use a plain permalink structure.

Хуков нет.

Возвращает

true|false. Whether to use a plain permalink structure.

Использование

wp_force_plain_post_permalink( $post, $sample );
$post(WP_Post/число/null)
Post ID or post object.
По умолчанию: global $post
$sample(true|false/null)
Whether to force consideration based on sample links. If omitted, a sample link is generated if a post object is passed with the filter property set to 'sample'.

Список изменений

С версии 5.7.0 Введена.

Код wp_force_plain_post_permalink() WP 5.7.1

<?php
function wp_force_plain_post_permalink( $post = null, $sample = null ) {
	if (
		null === $sample &&
		is_object( $post ) &&
		isset( $post->filter ) &&
		'sample' === $post->filter
	) {
		$sample = true;
	} else {
		$post   = get_post( $post );
		$sample = null !== $sample ? $sample : false;
	}

	if ( ! $post ) {
		return true;
	}

	$post_status_obj = get_post_status_object( get_post_status( $post ) );
	$post_type_obj   = get_post_type_object( get_post_type( $post ) );

	if ( ! $post_status_obj || ! $post_type_obj ) {
		return true;
	}

	if (
		// Publicly viewable links never have plain permalinks.
		is_post_status_viewable( $post_status_obj ) ||
		(
			// Private posts don't have plain permalinks if the user can read them.
			$post_status_obj->private &&
			current_user_can( 'read_post', $post->ID )
		) ||
		// Protected posts don't have plain links if getting a sample URL.
		( $post_status_obj->protected && $sample )
	) {
		return false;
	}

	return true;
}