wp_force_plain_post_permalink

The timeline below displays how wordpress function wp_force_plain_post_permalink has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.7

/**
 * Determine whether post should always use a plain permalink structure.
 *
 * @since 5.7.0
 *
 * @param WP_Post|int|null $post   Optional. Post ID or post object. Defaults to global $post.
 * @param bool|null        $sample Optional. 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'.
 * @return bool Whether to use a plain permalink structure.
 */
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 (is_post_status_viewable($post_status_obj) || $post_status_obj->private && current_user_can('read_post', $post->ID) || $post_status_obj->protected && $sample) {
        return false;
    }
    return true;
}