[wp-trac] [WordPress Trac] #8592: Private Pages not listed in the Parent dropdown
WordPress Trac
wp-trac at lists.automattic.com
Tue Aug 30 03:29:26 UTC 2011
#8592: Private Pages not listed in the Parent dropdown
-----------------------------+------------------------
Reporter: mtdewvirus | Owner: nacin
Type: feature request | Status: reviewing
Priority: normal | Milestone: 3.3
Component: Administration | Version: 2.7
Severity: major | Resolution:
Keywords: has-patch |
-----------------------------+------------------------
Changes (by kmklr72):
* cc: kmklr72 (added)
Comment:
Like davecpage, I ran into this issue for a client. I wanted to fix it
without hacking core, and this function seems to be working fine (based on
3.2.1 stable):
{{{
function admin_private_parent_metabox($output)
{
global $post;
$args = array(
'post_type' => $post->post_type,
'exclude_tree' => $post->ID,
'selected' => $post->post_parent,
'name' => 'parent_id',
'show_option_none' => __('(no parent)'),
'sort_column' => 'menu_order, post_title',
'echo' => 0,
'post_status' => array('publish', 'private'),
);
$defaults = array(
'depth' => 0,
'child_of' => 0,
'selected' => 0,
'echo' => 1,
'name' => 'page_id',
'id' => '',
'show_option_none' => '',
'show_option_no_change' => '',
'option_none_value' => '',
);
$r = wp_parse_args($args, $defaults);
extract($r, EXTR_SKIP);
$pages = get_pages($r);
$name = esc_attr($name);
// Back-compat with old system where both id and name were based
on $name argument
if (empty($id))
{
$id = $name;
}
if (!empty($pages))
{
$output = "<select name=\"$name\" id=\"$id\">\n";
if ($show_option_no_change)
{
$output .= "\t<option
value=\"-1\">$show_option_no_change</option>";
}
if ($show_option_none)
{
$output .= "\t<option value=\"" .
esc_attr($option_none_value) . "\">$show_option_none</option>\n";
}
$output .= walk_page_dropdown_tree($pages, $depth, $r);
$output .= "</select>\n";
}
return $output;
}
add_filter('wp_dropdown_pages', 'admin_private_parent_metabox');
}}}
As you might be able to tell, it is pretty much just a copy of
wp_dropdown_pages from /wp-includes/post_template.php with a few
customizations. It could probably do with being cleaned up, but it seems
to be doing what I want for now. Hopefully it will help someone here.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/8592#comment:129>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list