• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress core a2z

WordPress core a2z

WordPress core only

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / _deprecated_constructor() – Marks a constructor as deprecated and informs when it has been used.

You appear to be a bot. Output may be restricted

Description

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

Similar to _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.

Usage

_deprecated_constructor( $class, $version, $parent_class );

Parameters

$class
( string ) required – The class containing the deprecated constructor.
$version
( string ) required – The version of WordPress that deprecated the function.
$parent_class
( string ) optional – Optional. The parent class calling the deprecated constructor. Default empty string.

Returns

void

Source

File name: wordpress/wp-includes/functions.php
Lines:

1 to 76 of 76
function _deprecated_constructor( $class, $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        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, $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 ) {
        trigger_error(
          sprintf(
            /* translators: 1: PHP class name, 2: PHP parent class name, 3: Version number, 4: __construct() method. */
            __( 'The called constructor method for %1$s in %2$s is <strong>deprecated</strong> since version %3$s! Use %4$s instead.' ),
            $class,
            $parent_class,
            $version,
            '<code>__construct()</code>'
          ),
          E_USER_DEPRECATED
        );
      } else {
        trigger_error(
          sprintf(
            /* translators: 1: PHP class name, 2: Version number, 3: __construct() method. */
            __( 'The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ),
            $class,
            $version,
            '<code>__construct()</code>'
          ),
          E_USER_DEPRECATED
        );
      }
    } else {
      if ( $parent_class ) {
        trigger_error(
          sprintf(
            'The called constructor method for %1$s in %2$s is <strong>deprecated</strong> since version %3$s! Use %4$s instead.',
            $class,
            $parent_class,
            $version,
            '<code>__construct()</code>'
          ),
          E_USER_DEPRECATED
        );
      } else {
        trigger_error(
          sprintf(
            'The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.',
            $class,
            $version,
            '<code>__construct()</code>'
          ),
          E_USER_DEPRECATED
        );
      }
    }
  }

}
 

 View on GitHub View on Trac

Published: 25th November 2019 | Last updated: 21st August 2020

Primary Sidebar

Information

Function name: _deprecated_constructor
Plugin ref: WordPress
Version: 5.6
Sourcefile: wp-includes/functions.php
File ref: wp-includes/functions.php
API type: private
Deprecated?: No
API Letters: _,C,D

Footer

WP-a2z
WordPress core a2z
WordPress core only
WordPress 5.6
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  core.wp-a2z.org
© Copyright WP-a2z 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites