钩子文档

install_theme_overwrite_comparison

💡 云策文档标注

概述

本文档介绍 WordPress 中的 install_theme_overwrite_comparison 过滤器,用于在主题上传时自定义覆盖比较表的输出内容。该过滤器允许开发者修改显示当前主题与上传主题信息的表格。

关键要点

  • install_theme_overwrite_comparison 是一个过滤器,用于过滤主题上传覆盖时的比较表输出。
  • 过滤器接收三个参数:$tablestring(输出表格字符串)、$current_theme_data(当前主题的 WP_Theme 对象)和 $new_theme_data(上传主题数据的数组)。
  • 该过滤器在 WordPress 5.5.0 版本中引入,常用于 Theme_Installer_Skin::do_overwrite() 方法中,以检查主题是否可覆盖并输出相关 HTML。

代码示例

echo apply_filters( 'install_theme_overwrite_comparison', $table, $current_theme_data, $new_theme_data );

📄 原文内容

Filters the compare table output for overwriting a theme package on upload.

Parameters

$tablestring
The output table with Name, Version, Author, RequiresWP, and RequiresPHP info.
$current_theme_dataWP_Theme
Active theme data.
$new_theme_dataarray
Array with uploaded theme data.

Source

echo apply_filters( 'install_theme_overwrite_comparison', $table, $current_theme_data, $new_theme_data );

Changelog

Version Description
5.5.0 Introduced.