钩子文档

deprecated_constructor_run

💡 云策文档标注

概述

当调用一个已弃用的构造函数时,WordPress 会触发 deprecated_constructor_run 钩子。此钩子用于通知开发者构造函数已被弃用,并提供相关参数信息。

关键要点

  • 钩子名称:deprecated_constructor_run
  • 触发时机:当调用一个已弃用的构造函数时
  • 参数:$class_name(包含弃用构造函数的类名)、$version(WordPress 弃用该构造函数的版本)、$parent_class(调用弃用构造函数的父类名)
  • 相关函数:_deprecated_constructor() 用于标记构造函数为弃用并通知使用情况
  • 变更历史:WordPress 4.3.0 引入此钩子,4.5.0 添加了 $parent_class 参数

📄 原文内容

Fires when a deprecated constructor is called.

Parameters

$class_namestring
The class containing the deprecated constructor.
$versionstring
The version of WordPress that deprecated the function.
$parent_classstring
The parent class calling the deprecated constructor.

Source

do_action( 'deprecated_constructor_run', $class_name, $version, $parent_class );

Changelog

Version Description
4.5.0 Added the $parent_class parameter.
4.3.0 Introduced.