Do not allow a page to be its own parent.

git-svn-id: https://develop.svn.wordpress.org/trunk@1878 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2004-11-24 00:12:46 +00:00
parent 469d850946
commit 5710a6ac38
3 changed files with 15 additions and 3 deletions

View File

@ -615,10 +615,17 @@ function page_template_dropdown($default = '') {
}
function parent_dropdown($default = 0, $parent = 0, $level = 0) {
global $wpdb;
global $wpdb, $post_ID;
$items = $wpdb->get_results("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_status = 'static' ORDER BY menu_order");
if ($items) {
foreach ($items as $item) {
// A page cannot be it's own parent.
if (!empty($post_ID)) {
if ($item->ID == $post_ID) {
continue;
}
}
$pad = str_repeat(' ', $level * 3);
if ($item->ID == $default)
$current = ' selected="selected"';

View File

@ -34,7 +34,7 @@ window.onload = focusit;
</script>
<fieldset id="titlediv">
<legend><?php _e('Page Title') ?></legend>
<div><input type="text" name="post_title" size="30" tabindex="1" value="<?php echo $edited_post_title; ?>" id="title" /></div>
<div><input type="text" name="post_title" size="30" tabindex="1" value="<?php echo $edited_post_title; ?>" id="title" /></div>
</fieldset>
<fieldset id="commentstatusdiv">
<legend><?php _e('Discussion') ?></legend>

View File

@ -1332,10 +1332,15 @@ function preg_index($number, $matches = '') {
function get_page_uri($page) {
global $wpdb;
$page = $wpdb->get_row("SELECT post_name, post_parent FROM $wpdb->posts WHERE ID = '$page'");
$page = $wpdb->get_row("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE ID = '$page'");
$uri = urldecode($page->post_name);
// A page cannot be it's own parent.
if ($page->post_parent == $page->ID) {
return $uri;
}
while ($page->post_parent != 0) {
$page = $wpdb->get_row("SELECT post_name, post_parent FROM $wpdb->posts WHERE ID = '$page->post_parent'");
$uri = urldecode($page->post_name) . "/" . $uri;