Do not allow a page to be its own parent.
git-svn-id: http://svn.automattic.com/wordpress/trunk@1878 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
7c7133aa9a
commit
477e3344b8
|
@ -615,10 +615,17 @@ function page_template_dropdown($default = '') {
|
||||||
}
|
}
|
||||||
|
|
||||||
function parent_dropdown($default = 0, $parent = 0, $level = 0) {
|
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");
|
$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) {
|
if ($items) {
|
||||||
foreach ($items as $item) {
|
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);
|
$pad = str_repeat(' ', $level * 3);
|
||||||
if ($item->ID == $default)
|
if ($item->ID == $default)
|
||||||
$current = ' selected="selected"';
|
$current = ' selected="selected"';
|
||||||
|
|
|
@ -1332,10 +1332,15 @@ function preg_index($number, $matches = '') {
|
||||||
|
|
||||||
function get_page_uri($page) {
|
function get_page_uri($page) {
|
||||||
global $wpdb;
|
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);
|
$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) {
|
while ($page->post_parent != 0) {
|
||||||
$page = $wpdb->get_row("SELECT post_name, post_parent FROM $wpdb->posts WHERE ID = '$page->post_parent'");
|
$page = $wpdb->get_row("SELECT post_name, post_parent FROM $wpdb->posts WHERE ID = '$page->post_parent'");
|
||||||
$uri = urldecode($page->post_name) . "/" . $uri;
|
$uri = urldecode($page->post_name) . "/" . $uri;
|
||||||
|
|
Loading…
Reference in New Issue