#43848 closed enhancement (fixed)
Function "user_can_access_admin_page" refactor.
| Reported by: | rnaby | Owned by: | valentinbora |
|---|---|---|---|
| Priority: | lowest | Milestone: | 5.6 |
| Component: | Administration | Version: | |
| Severity: | normal | Keywords: | has-patch needs-refresh |
| Cc: | Focuses: | coding-standards |
Description
I think this user_can_access_admin_page function should looks more clean and better this way. Also added a description of the function.
Attachments (2)
Change History (9)
#2
@
7 years ago
- Keywords needs-refresh added; needs-testing removed
- Milestone Awaiting Review → Future Release
- Owner set to
- Priority normal → lowest
- Status new → accepted
Thanks for the patch @rnaby and sorry for the delay here. Unfortunately, the patch needs a refresh as it no longer applies cleanly onto trunk.
For reference, coding standards relevant docs:
#3
@
6 years ago
- Keywords close added
- Resolution → wontfix
- Status accepted → closed
I reviewed the proposed patch and compared it against the current implementation.
The proposed patch is mostly whitespace changes and merging of if statements.
For example (pseudo-code):
if( A ){
something
}
if( B ){
something
}
to
if( A || B ){
something
}
The current implementation is relatively concise and correct with WordPress coding standards. There's no need for this ticket to remain open.
#5
@
6 years ago
- Focuses coding-standards added
- Keywords close removed
- Milestone → 5.6
- Resolution wontfix
- Status closed → reopened
While I mostly agree with comment:3, I think there is some benefit in replacing these parts:
if ( current_user_can( $submenu_array[1] ) ) {
return true;
} else {
return false;
}
with:
return current_user_can( $submenu_array[1] );
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
The patch for the enhancement.