WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 8 months 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 5 years ago.
17891-2.diff (548 bytes) - added by sunnyratilal 3 years ago.
17891-3.patch (517 bytes) - added by pavelevap 8 months ago.

Download all attachments as: .zip

Change History (18)

@scribu
5 years ago

#1 @scribu
5 years ago

  • Severity changed from normal to minor

#2 @Viper007Bond
4 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.

@sunnyratilal
3 years ago

#3 @sunnyratilal
3 years ago

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

Patch refreshed.

#4 @jeremyfelt
2 years ago

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

#5 @wonderboymusic
8 months ago

  • Milestone changed from Awaiting Review to 4.4

#6 @wonderboymusic
8 months 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.

#7 @pavelevap
8 months ago

@since 4.4.0 is missing from hook changelog?

#8 @wonderboymusic
8 months ago

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

#9 follow-up: @chriscct7
8 months 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.

#10 @wonderboymusic
8 months ago

  • Keywords good-first-bug added

#11 in reply to: ↑ 9 @DrewAPicture
8 months 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.

#12 @chriscct7
8 months ago

Ah indeed you are correct.

#13 follow-up: @pavelevap
8 months 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.
...

@pavelevap
8 months ago

#14 in reply to: ↑ 13 @DrewAPicture
8 months 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!

#15 @DrewAPicture
8 months 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.