WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 8 days ago

#17891 closed enhancement (fixed)

Pass $post_type to 'restrict_manage_posts'

Reported by: scribu Owned by: DrewAPicture
Milestone: 4.4 Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: good-first-bug
Focuses: administration Cc:

Description

It would be nice if the 'restrict_manage_posts' hook received the post type as an argument, rather than having to check the global.

Attachments (3)

17891.diff (548 bytes) - added by scribu 4 years ago.
17891-2.diff (548 bytes) - added by sunnyratilal 2 years ago.
17891-3.patch (517 bytes) - added by pavelevap 8 days ago.

Download all attachments as: .zip

Change History (18)

@scribu4 years ago

comment:1 @scribu4 years ago

  • Severity changed from normal to minor

comment:2 @Viper007Bond3 years ago

  • Keywords needs-refresh added

Now that we're not passing around the $post_type global, we should instead pass the whole $this->screen object.

@sunnyratilal2 years ago

comment:3 @sunnyratilal2 years ago

  • Cc sunnyratilal5@… added
  • Keywords needs-refresh removed

Patch refreshed.

comment:4 @jeremyfelt19 months ago

  • Component changed from Administration to Posts, Post Types
  • Focuses admin added

comment:5 @wonderboymusic10 days ago

  • Milestone changed from Awaiting Review to 4.4

comment:6 @wonderboymusic10 days ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 33644:

The 'restrict_manage_posts' hook currently fires on the Post and Media list tables, but is passed zero arguments. Pass $post_type.

Props sunnyratilal, scribu.
Fixes #17891.

comment:7 @pavelevap10 days ago

@since 4.4.0 is missing from hook changelog?

comment:8 @wonderboymusic10 days ago

@pavelevap - wanna whip up a patch for some easy props?

comment:9 follow-up: @chriscct710 days ago

  • Keywords needs-docs added; has-patch removed
  • Resolution fixed deleted
  • Severity changed from minor to normal
  • Status changed from closed to reopened

The hook actually needs a full docbloc, see https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/php/#1-functions-and-class-methods. Shouldn't be more than a couple lines.

comment:10 @wonderboymusic9 days ago

  • Keywords good-first-bug added

comment:11 in reply to: ↑ 9 @DrewAPicture9 days ago

Replying to chriscct7:

The hook actually needs a full docbloc

Not sure what you're referring to. The 'restrict_manage_posts' hook is already fully documented in class-wp-posts-list-table. As @pavelevap pointed out, all we really need here is a changelog entry for the new parameter, unless I'm missing something.

comment:12 @chriscct79 days ago

Ah indeed you are correct.

comment:13 follow-up: @pavelevap8 days ago

Sure, I will add patch in a while...

I found similar docs, but I am not sure if there is any standard for this sentence?

Added `$post_type` parameter.
The `$post_type` parameter was added.
Introduced the `$post_type` parameter.
...

@pavelevap8 days ago

comment:14 in reply to: ↑ 13 @DrewAPicture8 days ago

  • Keywords needs-docs removed
  • Owner changed from wonderboymusic to DrewAPicture
  • Status changed from reopened to reviewing

Replying to pavelevap:

Sure, I will add patch in a while...

I found similar docs, but I am not sure if there is any standard for this sentence?

Added `$post_type` parameter.
The `$post_type` parameter was added.
Introduced the `$post_type` parameter.
...

Personally, I prefer the second one:

The `$post_type` parameter was added.

I'll fix it on commit. Thanks for the patch!

comment:15 @DrewAPicture8 days ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 33691:

Docs: Add a changelog entry for the $post_type parameter added to the restrict_manage_posts hook in [33644].

Props pavelevap
Fixes #17891.

Note: See TracTickets for help on using tickets.