WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 2 years ago

#6939 new enhancement

wp_list_pages() should also lists private pages if the user has capability 'read_private_pages'

Reported by: imwebgefunden Owned by: anonymous
Priority: normal Milestone: Future Release
Component: Template Version: 2.5.1
Severity: normal Keywords: has-patch featured gsoc needs-testing
Cc: steph@…, sirzooro, WordPress@…, wojtek.szkutnik@…

Description

If the user has the capability "read_private_pages" wp_list_pages() don't lists private pages in no way. I've noticed this problem by some comments on my "Role Manager" Plugin page.

Two patches are attached to this ticket.

wp_list_pages() gets a new option "include_private_pages". The default value is 1 for lists private pages too if the user has the capability "read_private_pages".
If private pages should not be listed also if the user has the cap "read_private_pages" the syntax is as an example:
wp_list_pages('title_li=<h2>Pages</h2>&include_private_pages=0');

The second patch is for get_pages() - with the same option and default value.

And of course: if a user don't has the cap "read_private_pages" private pages are listed in no case :)

Attachments (3)

post-template.diff (488 bytes) - added by imwebgefunden 5 years ago.
Patch for wp-includes/post-template.php
post.diff (1.2 KB) - added by imwebgefunden 5 years ago.
Patch for wp-includes/post.php
6939.diff (1.6 KB) - added by wojtek.szkutnik 3 years ago.

Download all attachments as: .zip

Change History (18)

imwebgefunden5 years ago

Patch for wp-includes/post-template.php

imwebgefunden5 years ago

Patch for wp-includes/post.php

comment:1 chodo5 years ago

This is a very useful patch!
I think it should be included in Wordpress.
Works like a charm for me.

comment:2 ryan5 years ago

  • Milestone changed from 2.5.2 to 2.9

Milestone 2.5.2 deleted

comment:3 Coolkevman5 years ago

Don't know if this help, but I can confirm that this bug is still present in WordPress 2.6.

comment:4 rovo895 years ago

  • Keywords has-patch added

I agree that this is a very useful patch and should be included in the next release. That is the one thing I have to change in the core after each update, although I use:

... WHERE (post_type = 'page' AND " . get_private_posts_cap_sql('page') . ") ...

The get_private_posts_cap_sql function does basically the same as in the patch here, but is already included in Wordpress and additionally lists the user's own private pages, even if they have no permission to read private posts.

comment:5 Denis-de-Bernardy4 years ago

  • Keywords neesd-patch close added; has-patch removed
  • Milestone changed from 2.9 to Future Release
  • Type changed from defect (bug) to enhancement

suggesting wontfix, personally. private pages don't belong in that menu. or then:

  • we should at least add an option to show them, off by default, for performance reasons
  • we may gain advantage to grab all pages, private or not, and use the walker to remove the private ones

comment:6 Denis-de-Bernardy4 years ago

  • Keywords needs-patch added; neesd-patch removed

comment:7 sillybean4 years ago

Respectfully disagreeing; private pages absolutely do belong in this menu. Where else would they go? Most sites have a single navigation menu. It makes sense to include the private pages there when needed rather than requiring a separate menu for them.

comment:8 sillybean4 years ago

  • Cc steph@… added

comment:9 nacin4 years ago

See also #8592

comment:10 sirzooro3 years ago

  • Cc sirzooro added

comment:11 voyagerfan57613 years ago

  • Cc WordPress@… added

comment:12 Denis-de-Bernardy3 years ago

  • Keywords bug-hunt added

comment:13 Denis-de-Bernardy3 years ago

  • Keywords featured added; close bug-hunt removed

wojtek.szkutnik3 years ago

comment:14 wojtek.szkutnik3 years ago

  • Cc wojtek.szkutnik@… added
  • Keywords has-patch gsoc needs-testing added; needs-patch wp_list_pages read_private_pages removed

comment:15 sillybean2 years ago

The patches on #8592 should resolve this problem and #4711.

Note: See TracTickets for help on using tickets.