Opened 4 years ago
Last modified 3 years ago
#54554 new enhancement
Allow returning content for wp_dropdown_roles()
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Future Release | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Role/Capability | Keywords: | has-patch dev-feedback |
| Focuses: | Cc: |
Description
Currently wp_dropdown_roles() function is set to echo the content instead of the option to echo or return the content. Similar wp_dropdown_* functions allows to echo or not the content.
Change History (8)
This ticket was mentioned in PR #2006 on WordPress/wordpress-develop by nithinjohn22.
4 years ago
#2
- Keywords has-patch added
This ticket was mentioned in Slack in #core by nithi22. View the logs.
3 years ago
#6
@
3 years ago
I tested the PR with the following code:
add_filter( 'admin_footer_text', function() {
echo '<select>';
wp_dropdown_roles( 'editor' );
echo '</select>';
} );
It returns the same result than before the patch.
and then I tested it with this snippet:
add_filter( 'admin_footer_text', function() {
$roles = wp_dropdown_roles( array(
'echo' => false,
) );
var_export( $roles );
} );
$roles is an array of roles.
Looks good to me 👍
#7
@
3 years ago
Ah, wait, no. In the above example, $roles is not an array. It's a string.
I can hardly see how to use it in real life. We should probably just return an array of user roles. Probably just returning the content of $editable_roles should be enough.
#8
@
3 years ago
- Keywords dev-feedback added
- Milestone changed from 6.1 to Future Release
I'm not sure about this. Every instance I see in core where wp_dropdown_roles is called, it's being output. wp_dropdown_roles only creates the options, not the outer select element.
One thing I could see going here is maybe a apply_filters call at the echo.
Marking for dev-feedback and moving to Future Release until this has a more solid direction.
Currently wp_dropdown_roles function only prints the elements for the role selectors not to display or retrieve the HTML like other dropdown functions.
Trac ticket: https://core.trac.wordpress.org/ticket/54554