Make WordPress Core

Opened 8 years ago

Closed 7 years ago

#37446 closed enhancement (fixed)

Introduce a filter for `self_admin_url()`

Reported by: flixos90's profile flixos90 Owned by: flixos90's profile flixos90
Milestone: 4.9 Priority: normal
Severity: normal Version: 3.1
Component: Administration Keywords: has-patch has-unit-tests
Focuses: multisite Cc:

Description

I'm currently building a plugin which includes an additional administration panel (like the network or user admin). However, the function self_admin_url() is impossible to adjust to that new functionality. I would like to be able to have it return the admin URL to my new administration panel if it is active.

Therefore I propose to introduce a new filter self_admin_url for the function. A developer could hook into that, check whether the custom administration panel is currently active and then adjust the returned URL accordingly.

Attachments (3)

37446.diff (1.1 KB) - added by flixos90 8 years ago.
37446.2.diff (1.1 KB) - added by j.hoffmann 8 years ago.
37446.3.diff (2.7 KB) - added by flixos90 7 years ago.

Download all attachments as: .zip

Change History (10)

@flixos90
8 years ago

#1 @flixos90
8 years ago

  • Keywords has-patch added; needs-patch removed

37446.diff introduces the filter.

#3 @DrewAPicture
8 years ago

  • Milestone changed from Awaiting Review to Future Release

+1. We should probably also pass the $scheme value to the filter for completeness.

#4 @flixos90
8 years ago

Related: #37526

@j.hoffmann
8 years ago

#5 @j.hoffmann
8 years ago

In 37446.2.diff I added the $scheme parameter.

@flixos90
7 years ago

#6 @flixos90
7 years ago

  • Keywords has-unit-tests added
  • Milestone changed from Future Release to 4.9
  • Owner set to flixos90
  • Status changed from new to assigned

In 37446.3.diff I added a few unit tests for self_admin_url().

It's currently not possible to test the function further without hacking a lot, since there is no way to influence function outcomes from e.g. is_network_admin(), since WP_Screen is final and cannot be mocked. The few tests that are there now at least perform the most basic checks and ensure the filter works.

#7 @flixos90
7 years ago

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

In 41060:

Multisite: Introduce a self_admin_url filter to adjust the URL to an administration panel.

Props j.hoffmann.
Fixes #37446.

Note: See TracTickets for help on using tickets.