quick_edit_dropdown_authors_args
云策文档标注
概述
quick_edit_dropdown_authors_args 是一个 WordPress 过滤器,用于修改 Quick Edit 界面中作者下拉菜单的生成参数。它允许开发者自定义 wp_dropdown_users() 函数的参数,以控制用户查询和显示选项。
关键要点
- 过滤器名称:quick_edit_dropdown_authors_args,用于过滤 Quick Edit 作者下拉菜单的参数。
- 参数:$users_opt(数组,传递给 wp_dropdown_users() 的参数)和 $bulk(布尔值,表示是否为批量操作)。
- 功能:基于 wp_dropdown_users() 的参数,支持用户查询、排序、筛选和显示选项的自定义。
- 相关函数:与 wp_dropdown_users() 和 WP_User_Query::prepare_query() 紧密关联,参数可继承自这些函数。
- 用途:在 WP_Posts_List_Table::inline_edit() 中使用,影响文章列表的 Quick Edit 功能。
代码示例
$users_opt = apply_filters( 'quick_edit_dropdown_authors_args', $users_opt, $bulk );注意事项
- 参数 $users_opt 是一个数组,包含如 show_option_all、orderby、include、role 等选项,具体可参考 wp_dropdown_users() 文档。
- capability 相关参数仅适用于数据库中存在或通过 'map_meta_cap' 过滤的能力,否则可能无效。
- who 参数已弃用,建议使用 capability 参数替代。
- 此过滤器自 WordPress 5.6.0 版本引入。
原文内容
Filters the arguments used to generate the Quick Edit authors drop-down.
Description
See also
Parameters
$users_optarray-
An array of arguments passed to wp_dropdown_users() .
More Arguments from wp_dropdown_users( … $args )
Array or string of arguments to generate a drop-down of users.
See WP_User_Query::prepare_query() for additional available arguments.show_option_allstringText to show as the drop-down default (all).
Default empty.show_option_nonestringText to show as the drop-down default when no users were found. Default empty.option_none_valueint|stringValue to use for$show_option_nonewhen no users were found. Default -1.hide_if_only_one_authorstringWhether to skip generating the drop-down if only one user was found. Default empty.orderbystringField to order found users by. Accepts user fields.
Default'display_name'.orderstringWhether to order users in ascending or descending order. Accepts'ASC'(ascending) or'DESC'(descending).
Default'ASC'.includeint[]|stringArray or comma-separated list of user IDs to include.
Default empty.excludeint[]|stringArray or comma-separated list of user IDs to exclude.
Default empty.multibool|intWhether to skip the ID attribute on the'select'element.
Accepts1|trueor0|false. Default0|false.showstringUser data to display. If the selected item is empty then the'user_login'will be displayed in parentheses.
Accepts any user field, or'display_name_with_login'to show the display name with user_login in parentheses.
Default'display_name'.echoint|boolWhether to echo or return the drop-down. Accepts1|true(echo) or0|false(return). Default1|true.selectedintWhich user ID should be selected. Default 0.include_selectedboolWhether to always include the selected user ID in the drop- down. Default false.namestringName attribute of select element. Default'user'.idstringID attribute of the select element. Default is the value of$name.classstringClass attribute of the select element. Default empty.blog_idintID of blog (Multisite only). Default is ID of the current blog.whostringDeprecated, use$capabilityinstead.
Which type of users to query. Accepts only an empty string or'authors'. Default empty (all users).rolestring|string[]An array or a comma-separated list of role names that users must match to be included in results. Note that this is an inclusive list: users must match *each* role. Default empty.role__instring[]An array of role names. Matched users must have at least one of these roles. Default empty array.role__not_instring[]An array of role names to exclude. Users matching one or more of these roles will not be included in results. Default empty array.capabilitystring|string[]An array or a comma-separated list of capability names that users must match to be included in results. Note that this is an inclusive list: users must match *each* capability.
Does NOT work for capabilities not in the database or filtered via ‘map_meta_cap’. Default empty.capability__instring[]An array of capability names. Matched users must have at least one of these capabilities.
Does NOT work for capabilities not in the database or filtered via ‘map_meta_cap’. Default empty array.capability__not_instring[]An array of capability names to exclude. Users matching one or more of these capabilities will not be included in results.
Does NOT work for capabilities not in the database or filtered via ‘map_meta_cap’. Default empty array.
$bulkbool-
A flag to denote if it’s a bulk action.
Source
$users_opt = apply_filters( 'quick_edit_dropdown_authors_args', $users_opt, $bulk );
Changelog
| Version | Description |
|---|---|
| 5.6.0 | Introduced. |