钩子文档

handle_network_bulk_actions-{$screen}

💡 云策文档标注

概述

handle_network_bulk_actions-{$screen} 是一个 WordPress 钩子,用于处理自定义批量操作。它允许开发者在执行批量操作时修改重定向链接,以向用户提供成功或失败的反馈。

关键要点

  • 钩子名称包含动态部分 {$screen},代表当前屏幕 ID。
  • 主要参数包括 $redirect_url(重定向 URL)、$action(操作名称)、$items(操作项数组)和 $site_id(站点 ID)。
  • 适用于网络管理界面中的批量操作场景,如主题或插件的管理。

代码示例

$referer = apply_filters( "handle_network_bulk_actions-{$screen}", $referer, $action, $themes, $id ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores

注意事项

  • 钩子名称使用连字符而非下划线,需注意 WordPress 命名规范。
  • 从 WordPress 4.7.0 版本开始引入。

📄 原文内容

Fires when a custom bulk action should be handled.

Description

The redirect link should be modified with success or failure feedback from the action to be used to display feedback to the user.

The dynamic portion of the hook name, $screen, refers to the current screen ID.

Parameters

$redirect_urlstring
The redirect URL.
$actionstring
The action being taken.
$itemsarray
The items to take the action on.
$site_idint
The site ID.

Source

$referer = apply_filters( "handle_network_bulk_actions-{$screen}", $referer, $action, $themes, $id ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores

Changelog

Version Description
4.7.0 Introduced.