wpseek.com
A WordPress-centric search engine for devs and theme authors
wp_force_plain_post_permalink › WordPress Function
Since5.7.0
Deprecatedn/a
› wp_force_plain_post_permalink ( $post = null, $sample = null )
Parameters: (2) |
|
Returns: |
|
Defined at: |
|
Codex: |
Determine whether post should always use a plain permalink structure.
Related Functions: get_post_permalink, post_permalink, wp_ajax_get_permalink, previous_post_link, get_parent_post_rel_link
Source
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;
}