From d79ad8242bbdb7b5461b9db2d2db4649f093e536 Mon Sep 17 00:00:00 2001
From: jrfnl <jrfnl@users.noreply.github.com>
Date: Wed, 21 Jun 2017 23:16:40 +0200
Subject: [PATCH] Add new `_deprecated_class()` function.

---
 src/wp-includes/functions.php | 57 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
index 828f123..21ba238 100644
--- a/src/wp-includes/functions.php
+++ b/src/wp-includes/functions.php
@@ -4090,6 +4090,63 @@ function _deprecated_hook( $hook, $version, $replacement = null, $message = null
 }
 
 /**
+ * Mark a class as deprecated and inform when it has been used.
+ *
+ * There is a {@see 'hook deprecated_class_run'} that will be called that can be used
+ * to get the backtrace up to what file and function called the deprecated
+ * class.
+ *
+ * The current behavior is to trigger a user error if `WP_DEBUG` is true.
+ *
+ * This function is to be used in the class constructor for every class that is deprecated.
+ *
+ * @since 4.9.0
+ * @access private
+ *
+ * @param string $class       The class being instantiated.
+ * @param string $version     The version of WordPress that deprecated the class.
+ * @param string $replacement Optional. The class or function that should have been called. Default null.
+ */
+function _deprecated_class( $class, $version, $replacement = null ) {
+
+	/**
+	 * Fires when a deprecated class is called.
+	 *
+	 * @since 4.9.0
+	 *
+	 * @param string $class       The class being instantiated.
+	 * @param string $replacement The class or function that should have been called.
+	 * @param string $version     The version of WordPress that deprecated the class.
+	 */
+	do_action( 'deprecated_class_run', $function, $replacement, $version );
+
+	/**
+	 * Filters whether to trigger an error for deprecated classes.
+	 *
+	 * @since 4.9.0
+	 *
+	 * @param bool $trigger Whether to trigger the error for deprecated classes. Default true.
+	 */
+	if ( WP_DEBUG && apply_filters( 'deprecated_class_trigger_error', true ) ) {
+		if ( function_exists( '__' ) ) {
+			if ( ! is_null( $replacement ) ) {
+				/* translators: 1: PHP class name, 2: version number, 3: alternative clas or function name */
+				trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $function, $version, $replacement ), E_USER_DEPRECATED );
+			} else {
+				/* translators: 1: PHP class name, 2: version number */
+				trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ), E_USER_DEPRECATED );
+			}
+		} else {
+			if ( ! is_null( $replacement ) ) {
+				trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $function, $version, $replacement ), E_USER_DEPRECATED );
+			} else {
+				trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ), E_USER_DEPRECATED );
+			}
+		}
+	}
+}
+
+/**
  * Mark something as being incorrectly called.
  *
  * There is a hook {@see 'doing_it_wrong_run'} that will be called that can be used
-- 
2.10.1.windows.1

