if ( empty( $post->ID
) ) { return false;
} if ( 'page' ===
$post->post_type
) { return get_page_link( $post,
$leavename,
$sample );
} elseif ( 'attachment' ===
$post->post_type
) { return get_attachment_link( $post,
$leavename );
} elseif ( in_array( $post->post_type,
get_post_types( array
( '_builtin' => false
) ), true
) ) { return get_post_permalink( $post,
$leavename,
$sample );
} $permalink =
get_option( 'permalink_structure'
);
/**
* Filters the permalink structure for a post before token replacement occurs.
*
* Only applies to posts with post_type of 'post'.
*
* @since 3.0.0
*
* @param string $permalink The site's permalink structure.
* @param WP_Post $post The post in question.
* @param bool $leavename Whether to keep the post name.
*/