<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[12536] trunk/wp-includes/functions.php:
Add new function _deprecated_argument()
to be used for marking arguments as deprecated so that with WP_DEBUG enabled developers can see they need to review and update their code
.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/12536">12536</a></dd>
<dt>Author</dt> <dd>westi</dd>
<dt>Date</dt> <dd>2009-12-24 11:06:00 +0000 (Thu, 24 Dec 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add new function _deprecated_argument() to be used for marking arguments as deprecated so that with WP_DEBUG enabled developers can see they need to review and update their code. See <a href="http://trac.wordpress.org/ticket/11386">#11386</a> props nacin.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesfunctionsphp">trunk/wp-includes/functions.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/functions.php (12535 => 12536)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/functions.php        2009-12-24 10:53:34 UTC (rev 12535)
+++ trunk/wp-includes/functions.php        2009-12-24 11:06:00 UTC (rev 12536)
</span><span class="lines">@@ -3008,7 +3008,50 @@
</span><span class="cx">                         trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $file, $version ) );
</span><span class="cx">         }
</span><span class="cx"> }
</span><ins>+/**
+ * Marks a function argument as deprecated and informs when it has been used.
+ *
+ * This function is to be used whenever a deprecated function argument is used.
+ * Before this function is called, the argument must be checked for whether it was
+ * used by comparing it to its default value or evaluating whether it is empty.
+ * For example:
+ * <code>
+ * if ( !empty($deprecated) )
+ *         _deprecated_argument( __FUNCTION__, 'deprecated', '0.0' );
+ * </code>
+ *
+ * There is a hook deprecated_argument_run that will be called that can be used
+ * to get the backtrace up to what file and function used the deprecated
+ * argument.
+ *
+ * The current behavior is to trigger an user error if WP_DEBUG is true.
+ *
+ * @package WordPress
+ * @package Debug
+ * @since 3.0.0
+ * @access private
+ *
+ * @uses do_action() Calls 'deprecated_argument_run' and passes the function and argument names and what to use instead.
+ * @uses apply_filters() Calls 'deprecated_argument_trigger_error' and expects boolean value of true to do trigger or false to not trigger error.
+ *
+ * @param string $function The function that was called
+ * @param string $argument The name of the deprecated argument that was used
+ * @param string $version The version of WordPress that deprecated the function
+ * @param string $message Optional. A message regarding the change.
+ */
+function _deprecated_argument($function, $argument, $version, $message = null) {
</ins><span class="cx">
</span><ins>+        do_action('deprecated_argument_run', $function, $argument, $message);
+
+        // Allow plugin to filter the output error trigger
+        if( WP_DEBUG && apply_filters( 'deprecated_argument_trigger_error', true ) ) {
+                if( !is_null($replacement) )
+                        trigger_error( sprintf( __('The %1$s argument of %2$s is <strong>deprecated</strong> since version %3$s! %4$s'), $function, $argument, $version, $message ) );
+                else
+                        trigger_error( sprintf( __('The %1$s argument of %2$s is <strong>deprecated</strong> since version %3$s with no alternative available.'), $function, $argument, $version ) );
+        }
+}
+
</ins><span class="cx"> /**
</span><span class="cx"> * Is the server running earlier than 1.5.0 version of lighttpd
</span><span class="cx"> *
</span></span></pre>
</div>
</div>
</body>
</html>