2005-10-12: WordPress hack … just a note to myself
Hack for classes.php in line 315 (1.5.2). It allows two (sub-)pages to have the same name (slug):
$temp = dirname(
str_replace(
'%2F',
'/',
urlencode($q['pagename'])));
$names = explode('/', $temp);
$parent = null;
foreach ($names as $name) {
$name = sanitize_title($name);
$query = "SELECT ID " .
"FROM $wpdb->posts " .
"WHERE post_name='$name'" .
(isset($parent) ?
" AND post_parent=$parent" :
"");
$parent = null;
$parent = $wpdb->get_var($query);
if (!isset($parent)) {
// an error occured, continue as normal
$parent = null;
break;
}
}
$q['pagename'] = sanitize_title(
basename(
str_replace(
'%2F',
'/',
urlencode($q['pagename']))));
$q['name'] = $q['pagename'];
$where .=
" AND post_name = '" .
$q['pagename'] .
"'" .
(isset($parent) ?
" AND post_parent=$parent" :
"");
Another hack: allow users with user level >= 5 to edit other user’s posts/pages. This was required for our department’s website. post-functions.phpfunctions-post.php line 352 (1.5.2):
if ((($user_id == $post_author_data->ID) &&
!($post->post_status == 'publish' &&
$author_data->user_level < 2)) ||
($author_data->user_level >
$post_author_data->user_level) ||
(($author_data->user_level >=
$post_author_data->user_level) &&
($author_data->user_level >= 5)) ||
($author_data->user_level >= 10) )
{
return true;
} else {
return false;
}
September 2nd, 2006 at 01:33
Thanks for the same-page-name hack. Saved me, I really needed it.
Couldn’t find it anywhere else — shocking, because it’s so damned vital to doing static pages right.
Thanks again –
Karl