Make WordPress Core

Opened 9 years ago

Closed 6 years ago

Last modified 5 years ago

#42791 closed enhancement (fixed)

wp_add_dashboard_widget() should accept location and priority parameters

Reported by: johnbillion Owned by: johnbillion
Priority: normal Milestone: 5.6
Component: Administration Version:
Severity: normal Keywords: has-patch has-unit-tests commit
Cc: Focuses:

Description

The wp_add_dashboard_widget() function should accept $location and $priority parameters to bring the function inline with add_meta_box(), which it ultimately calls.

Attachments (6)

42791.diff (2.4 KB ) - added by davidjlaietta 9 years ago.
42791.2.diff (2.5 KB ) - added by davidjlaietta 9 years ago.
42791.3.diff (2.2 KB ) - added by soulseekah 8 years ago.
Why not set $priority = 'core' and $location = 'normal' to begin with? Why the whole 'default' dance? See 3rd diff version based on 2nd. Also removed tabs from docblock.
42791.4.diff (2.5 KB ) - added by soulseekah 8 years ago.
Enforce default priority and location when null is supplied
42791.tests.diff (1.9 KB ) - added by soulseekah 8 years ago.
The unit test
42791.5.diff (6.0 KB ) - added by johnbillion 6 years ago.

Download all attachments as: .zip

Change History (17)

@davidjlaietta
9 years ago

#1 @davidjlaietta
9 years ago

Attached diff includes $location and $priority arguments, and maintains similar logic for wp_add_dashboard_widget.

If location is not set, it'll be set to normal unless it's a side widget. If priority is not set it will be set to core unless dashboard_browser_nag is set, then it'll be set to high.

New usage:

wp_add_dashboard_widget( 'widget_id', 'Widget Name', callback_function, control_callback, array(), 'side', 'high' );

#2 @chetan200891
9 years ago

  • Keywords has-patch added; needs-patch removed

#3 @DrewAPicture
9 years ago

  • Keywords needs-unit-tests added
  • Owner set to davidjlaietta
  • Status newassigned

Hi @davidjlaietta, thanks for the patch! I've assigned the ticket to you to mark this good-first-bug as "claimed". Sorry for the delay in response.

I did a first pass on the patch, and the big standouts that are still missing are changelog entries for the new parameters in the DocBlock, and we could probably also benefit from unit tests here as well.

For info on changelog entries, check out this article in the core handbook.

#4 @davidjlaietta
9 years ago

The updated patch includes a changelog entry in the docblock

@soulseekah
8 years ago

Why not set $priority = 'core' and $location = 'normal' to begin with? Why the whole 'default' dance? See 3rd diff version based on 2nd. Also removed tabs from docblock.

@soulseekah
8 years ago

Enforce default priority and location when null is supplied

@soulseekah
8 years ago

The unit test

#5 @soulseekah
8 years ago

  • Keywords has-unit-tests added; needs-unit-tests removed

#6 @johnbillion
6 years ago

  • Keywords good-first-bug removed
  • Milestone Awaiting Review5.6
  • Owner changed from davidjlaietta to johnbillion
  • Status assignedreviewing

@johnbillion
6 years ago

#7 @johnbillion
6 years ago

  • Keywords commit added

42791.5.diff is a refreshed patch with improved docs. I think this is ready to go.

#8 @johnbillion
6 years ago

  • Resolutionfixed
  • Status reviewingclosed

In 49123:

Administration: Allow context and priority to be specified when adding dashboard widgets.

Props davidjlaietta, soulseekah, johnbillion

Fixes #42791

#9 @SergeyBiryukov
6 years ago

In 49124:

Docs: Correct comments in test_wp_add_dashboard_widget() per the documentation standards.

See #42791.

This ticket was mentioned in Slack in #core by peterwilsoncc. View the logs.


5 years ago

#11 @kirasong
5 years ago

#32922 was marked as a duplicate.

Note: See TracTickets for help on using tickets.