Title: _deprecated_constructor
Published: August 18, 2015
Last modified: May 20, 2026

---

# _deprecated_constructor( string $class_name, string $version, string $parent_class = '' )

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/_deprecated_constructor/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/_deprecated_constructor/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/_deprecated_constructor/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/_deprecated_constructor/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/_deprecated_constructor/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/_deprecated_constructor/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/_deprecated_constructor/?output_format=md#wp--skip-link--target)

Marks a constructor as deprecated and informs when it has been used.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/_deprecated_constructor/?output_format=md#description)󠁿

Similar to [_deprecated_function()](https://developer.wordpress.org/reference/functions/_deprecated_function/),
but with different strings. Used to remove PHP4-style constructors.

The current behavior is to trigger a user error if `WP_DEBUG` is true.

This function is to be used in every PHP4-style constructor method that is deprecated.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/_deprecated_constructor/?output_format=md#parameters)󠁿

 `$class_name`stringrequired

The class containing the deprecated constructor.

`$version`stringrequired

The version of WordPress that deprecated the function.

`$parent_class`stringoptional

The parent class calling the deprecated constructor.

Default:`''`

## 󠀁[Source](https://developer.wordpress.org/reference/functions/_deprecated_constructor/?output_format=md#source)󠁿

    ```php
    function _deprecated_constructor( $class_name, $version, $parent_class = '' ) {

    	/**
    	 * Fires when a deprecated constructor is called.
    	 *
    	 * @since 4.3.0
    	 * @since 4.5.0 Added the `$parent_class` parameter.
    	 *
    	 * @param string $class_name   The class containing the deprecated constructor.
    	 * @param string $version      The version of WordPress that deprecated the function.
    	 * @param string $parent_class The parent class calling the deprecated constructor.
    	 */
    	do_action( 'deprecated_constructor_run', $class_name, $version, $parent_class );

    	/**
    	 * Filters whether to trigger an error for deprecated functions.
    	 *
    	 * `WP_DEBUG` must be true in addition to the filter evaluating to true.
    	 *
    	 * @since 4.3.0
    	 *
    	 * @param bool $trigger Whether to trigger the error for deprecated functions. Default true.
    	 */
    	if ( WP_DEBUG && apply_filters( 'deprecated_constructor_trigger_error', true ) ) {
    		if ( function_exists( '__' ) ) {
    			if ( $parent_class ) {
    				$message = sprintf(
    					/* translators: 1: PHP class name, 2: PHP parent class name, 3: Version number, 4: __construct() method. */
    					__( 'The called constructor method for %1$s class in %2$s is <strong>deprecated</strong> since version %3$s! Use %4$s instead.' ),
    					$class_name,
    					$parent_class,
    					$version,
    					'<code>__construct()</code>'
    				);
    			} else {
    				$message = sprintf(
    					/* translators: 1: PHP class name, 2: Version number, 3: __construct() method. */
    					__( 'The called constructor method for %1$s class is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ),
    					$class_name,
    					$version,
    					'<code>__construct()</code>'
    				);
    			}
    		} else {
    			if ( $parent_class ) {
    				$message = sprintf(
    					'The called constructor method for %1$s class in %2$s is <strong>deprecated</strong> since version %3$s! Use %4$s instead.',
    					$class_name,
    					$parent_class,
    					$version,
    					'<code>__construct()</code>'
    				);
    			} else {
    				$message = sprintf(
    					'The called constructor method for %1$s class is <strong>deprecated</strong> since version %2$s! Use %3$s instead.',
    					$class_name,
    					$version,
    					'<code>__construct()</code>'
    				);
    			}
    		}

    		wp_trigger_error( '', $message, E_USER_DEPRECATED );
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/functions.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/functions.php#L5632)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/functions.php#L5632-L5696)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/_deprecated_constructor/?output_format=md#hooks)󠁿

 [do_action( ‘deprecated_constructor_run’, string $class_name, string $version, string $parent_class )](https://developer.wordpress.org/reference/hooks/deprecated_constructor_run/)

Fires when a deprecated constructor is called.

 [apply_filters( ‘deprecated_constructor_trigger_error’, bool $trigger )](https://developer.wordpress.org/reference/hooks/deprecated_constructor_trigger_error/)

Filters whether to trigger an error for deprecated functions.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/_deprecated_constructor/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_trigger_error()](https://developer.wordpress.org/reference/functions/wp_trigger_error/)`wp-includes/functions.php` |

Generates a user-level error/warning/notice/deprecation message.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [do_action()](https://developer.wordpress.org/reference/functions/do_action/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to an action hook.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

[Show 2 more](https://developer.wordpress.org/reference/functions/_deprecated_constructor/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/_deprecated_constructor/?output_format=md#)

| Used by | Description | 
| [WP_User_Search::WP_User_Search()](https://developer.wordpress.org/reference/classes/wp_user_search/wp_user_search/)`wp-admin/includes/deprecated.php` |

PHP4 Constructor – Sets up the object properties.

  | 
| [POMO_CachedFileReader::POMO_CachedFileReader()](https://developer.wordpress.org/reference/classes/pomo_cachedfilereader/pomo_cachedfilereader/)`wp-includes/pomo/streams.php` |

PHP4 constructor.

  | 
| [POMO_CachedIntFileReader::POMO_CachedIntFileReader()](https://developer.wordpress.org/reference/classes/pomo_cachedintfilereader/pomo_cachedintfilereader/)`wp-includes/pomo/streams.php` |

PHP4 constructor.

  | 
| [POMO_FileReader::POMO_FileReader()](https://developer.wordpress.org/reference/classes/pomo_filereader/pomo_filereader/)`wp-includes/pomo/streams.php` |

PHP4 constructor.

  | 
| [POMO_StringReader::POMO_StringReader()](https://developer.wordpress.org/reference/classes/pomo_stringreader/pomo_stringreader/)`wp-includes/pomo/streams.php` |

PHP4 constructor.

  | 
| [POMO_Reader::POMO_Reader()](https://developer.wordpress.org/reference/classes/pomo_reader/pomo_reader/)`wp-includes/pomo/streams.php` |

PHP4 constructor.

  | 
| [Translation_Entry::Translation_Entry()](https://developer.wordpress.org/reference/classes/translation_entry/translation_entry/)`wp-includes/pomo/entry.php` |

PHP4 constructor.

  | 
| [WP_Widget_Factory::WP_Widget_Factory()](https://developer.wordpress.org/reference/classes/wp_widget_factory/wp_widget_factory/)`wp-includes/class-wp-widget-factory.php` |

PHP4 constructor.

  | 
| [WP_Widget::WP_Widget()](https://developer.wordpress.org/reference/classes/wp_widget/wp_widget/)`wp-includes/class-wp-widget.php` |

PHP4 constructor.

  |

[Show 4 more](https://developer.wordpress.org/reference/functions/_deprecated_constructor/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/_deprecated_constructor/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/_deprecated_constructor/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.4.0](https://developer.wordpress.org/reference/since/5.4.0/) | The error type is now classified as E_USER_DEPRECATED (used to default to E_USER_NOTICE). | 
| [4.5.0](https://developer.wordpress.org/reference/since/4.5.0/) | Added the `$parent_class` parameter. | 
| [4.3.0](https://developer.wordpress.org/reference/since/4.3.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2F_deprecated_constructor%2F)
before being able to contribute a note or feedback.