2013-02-12, 02:29:41
@czk
No need to read the post file to get the current slug. It could be like this:
(It may be even easier... it's just a quickie without thinking too much)
posts.xml contains the slug for every post, but the post files themselves don't have it, because the file name (without the .xml suffix) is the post slug.
No need to read the post file to get the current slug. It could be like this:
PHP Code:
function nm_post_slug($echo=true) {
global $NMPAGEURL;
$slug = false;
if (isset($_GET['post']) && strval(get_page_slug(false)) == $NMPAGEURL) {
$file = NMPOSTPATH . $_GET['post'] . '.xml';
if (dirname(realpath($file)) == realpath(NMPOSTPATH)) { // no path traversal
$slug = $_GET['post'];
if ($echo) echo $slug;
}
}
return $slug;
}
(It may be even easier... it's just a quickie without thinking too much)
posts.xml contains the slug for every post, but the post files themselves don't have it, because the file name (without the .xml suffix) is the post slug.