media_row_actions
云策文档标注
概述
media_row_actions 是一个 WordPress 过滤器,用于自定义媒体库列表中每个附件的操作链接。它允许开发者修改或添加操作项,如编辑、删除、查看等。
关键要点
- 过滤器名称:media_row_actions
- 参数:$actions(操作链接数组)、$post(当前附件的 WP_Post 对象)、$detached(布尔值,指示媒体是否未附加到任何文章)
- 默认操作链接包括 'Edit'、'Delete Permanently'、'View'、'Copy URL' 和 'Download file'
- 源调用:apply_filters( 'media_row_actions', $actions, $post, $this->detached )
- 相关函数:WP_Media_List_Table::_get_row_actions()
- 引入版本:2.8.0
注意事项
用户贡献笔记指出,$actions 参数是一个键值对数组,键如 'edit'、'view',值为显示的 HTML 内容,开发者应据此进行自定义操作。
原文内容
Filters the action links for each attachment in the Media list table.
Parameters
Source
return apply_filters( 'media_row_actions', $actions, $post, $this->detached );
Changelog
| Version | Description |
|---|---|
| 2.8.0 | Introduced. |
Skip to note 2 content
jakeparis
The above description of the
$actionparameter is confusing. The paramter consists of keys, which by default (as of this writing) are:edit,delete,view,copy, anddownload.Each key’s value is html to display in the action row.
For example:
<br />
array(<br />
'edit' => '<a href="https://example.com/wp-admin/post.php?post=123&action=edit" aria-label="Edit “YardScaping_Spring-Lawn-Article_final_5-23-08”">Edit</a>',<br />
'view' => '<a href="https://trustees.ddev.site/?attachment_id=43897" aria-label="View “YardScaping_Spring-Lawn-Article_final_5-23-08”" rel="bookmark">View</a>',<br />
...<br />
)<br />