Ticket #11386: 11386.7.diff

File 11386.7.diff, 15.1 KB (added by nacin, 3 years ago)

Simplified _deprecated_argument() - sans typos.

Line 
1Index: wp-admin/includes/image.php
2===================================================================
3--- wp-admin/includes/image.php (revision 12527)
4+++ wp-admin/includes/image.php (working copy)
5@@ -17,9 +17,12 @@
6  *
7  * @param mixed $file Filename of the original image, Or attachment id.
8  * @param int $max_side Maximum length of a single side for the thumbnail.
9+ * @param mixed $deprecated Not used.
10  * @return string Thumbnail path on success, Error string on failure.
11  */
12 function wp_create_thumbnail( $file, $max_side, $deprecated = '' ) {
13+       if ( !empty( $deprecated ) )
14+               _deprecated_argument( __FUNCTION__, '0.0' );
15        $thumbpath = image_resize( $file, $max_side, $max_side );
16        return apply_filters( 'wp_create_thumbnail', $thumbpath );
17 }
18Index: wp-admin/includes/meta-boxes.php
19===================================================================
20--- wp-admin/includes/meta-boxes.php    (revision 12527)
21+++ wp-admin/includes/meta-boxes.php    (working copy)
22@@ -639,6 +639,9 @@
23 function xfn_check($class, $value = '', $deprecated = '') {
24        global $link;
25 
26+       if ( !empty( $deprecated ) )
27+               _deprecated_argument( __FUNCTION__, '0.0' );
28+
29        $link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: '';
30        $rels = preg_split('/\s+/', $link_rel);
31 
32Index: wp-admin/includes/upgrade.php
33===================================================================
34--- wp-admin/includes/upgrade.php       (revision 12527)
35+++ wp-admin/includes/upgrade.php       (working copy)
36@@ -33,9 +33,12 @@
37  * @param null $deprecated Optional. Not used.
38  * @return array Array keys 'url', 'user_id', 'password', 'password_message'.
39  */
40-function wp_install($blog_title, $user_name, $user_email, $public, $deprecated='') {
41+function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '' ) {
42        global $wp_rewrite;
43 
44+       if ( !empty( $deprecated ) )
45+               _deprecated_argument( __FUNCTION__, '2.6' );
46+
47        wp_check_mysql_version();
48        wp_cache_flush();
49        make_db_current_silent();
50Index: wp-app.php
51===================================================================
52--- wp-app.php  (revision 12527)
53+++ wp-app.php  (working copy)
54@@ -884,10 +884,12 @@
55         *
56         * @since 2.2.0
57         *
58-        * @param mixed $deprecated Optional, not used.
59+        * @param mixed $deprecated Not used.
60         * @return string
61         */
62        function get_categories_url($deprecated = '') {
63+               if ( !empty( $deprecated ) )
64+                       _deprecated_argument( __FUNCTION__, '2.5' );
65                return $this->app_base . $this->CATEGORIES_PATH;
66        }
67 
68Index: wp-includes/author-template.php
69===================================================================
70--- wp-includes/author-template.php     (revision 12538)
71+++ wp-includes/author-template.php     (working copy)
72@@ -22,6 +22,10 @@
73  */
74 function get_the_author($deprecated = '') {
75        global $authordata;
76+
77+       if ( !empty( $deprecated ) )
78+               _deprecated_argument( __FUNCTION__, '0.0' );
79+
80        return apply_filters('the_author', is_object($authordata) ? $authordata->display_name : null);
81 }
82 
83@@ -44,11 +48,9 @@
84  * @param string $deprecated_echo Deprecated. Use get_the_author(). Echo the string or return it.
85  * @return string The author's display name, from get_the_author().
86  */
87-function the_author($deprecated = '', $deprecated_echo = true) {
88-       if ( !empty($deprecated) )
89-               _deprecated_argument(__FUNCTION__, 'deprecated', '1.5');
90-       if ( $deprecated_echo !== true )
91-               _deprecated_argument(__FUNCTION__, 'deprecated_echo', '1.5', __('Use get_the_author() instead if you do not want the value echoed.'));
92+function the_author( $deprecated = '', $deprecated_echo = true ) {
93+       if ( !empty( $deprecated ) || $deprecated_echo !== true )
94+               _deprecated_argument( __FUNCTION__, '1.5', $deprecated_echo !== true ? __('Use get_the_author() instead if you do not want the value echoed.') : null );
95        if ( $deprecated_echo )
96                echo get_the_author();
97        return get_the_author();
98@@ -182,7 +184,7 @@
99  */
100 function the_author_posts_link($deprecated = '') {
101        if ( !empty( $deprecated ) )
102-               _deprecated_argument(__FUNCTION__, 'deprecated', '0.0');
103+               _deprecated_argument( __FUNCTION__, '0.0' );
104 
105        global $authordata;
106        $link = sprintf(
107Index: wp-includes/comment-template.php
108===================================================================
109--- wp-includes/comment-template.php    (revision 12538)
110+++ wp-includes/comment-template.php    (working copy)
111@@ -507,11 +507,8 @@
112  * @param bool $deprecated_2 Not Used
113  */
114 function comments_link( $deprecated_1 = '', $deprecated_2 = '' ) {
115-       if ( !empty( $deprecated_1 ) )
116-               _deprecated_argument(__FUNCTION__, 'deprecated_1', '0.0');
117-       if ( !empty( $deprecated_2 ) )
118-               _deprecated_argument(__FUNCTION__, 'deprecated_2', '0.0');
119-
120+       if ( !empty( $deprecated_1 ) || empty( $deprecated_2 ) )
121+               _deprecated_argument( __FUNCTION__, '0.0' );
122        echo get_comments_link();
123 }
124 
125@@ -554,6 +551,10 @@
126  */
127 function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {
128        global $id;
129+
130+       if ( !empty( $deprecated ) )
131+               _deprecated_argument( __FUNCTION__, '0.0' );
132+
133        $number = get_comments_number($id);
134 
135        if ( $number > 1 )
136@@ -696,12 +697,16 @@
137  * @since 0.71
138  * @uses get_trackback_url() Gets the trackback url for the current post
139  *
140- * @param bool $deprecated Remove backwards compat in 2.5
141+ * @param bool $deprecated_echo Remove backwards compat in 2.5
142  * @return void|string Should only be used to echo the trackback URL, use get_trackback_url() for the result instead.
143  */
144-function trackback_url($deprecated = true) {
145-       if ($deprecated) echo get_trackback_url();
146-       else return get_trackback_url();
147+function trackback_url( $deprecated_echo = true ) {
148+       if ( $deprecated_echo !== true )
149+               _deprecated_argument( __FUNCTION__, '2.5', __('Use get_trackback_url() instead if you do not want the value echoed.') );
150+       if ( $deprecated_echo )
151+               echo get_trackback_url();
152+       else
153+               return get_trackback_url();
154 }
155 
156 /**
157@@ -712,6 +717,9 @@
158  * @param int $deprecated Not used (Was $timezone = 0)
159  */
160 function trackback_rdf($deprecated = '') {
161+       if ( !empty( $deprecated ) )
162+               _deprecated_argument( __FUNCTION__, '2.5' );
163+
164        if (stripos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') === false) {
165                echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
166                                xmlns:dc="http://purl.org/dc/elements/1.1/"
167Index: wp-includes/comment.php
168===================================================================
169--- wp-includes/comment.php     (revision 12538)
170+++ wp-includes/comment.php     (working copy)
171@@ -1511,9 +1511,9 @@
172  * @param int $deprecated Not Used.
173  * @return bool|string False on failure, string containing URI on success.
174  */
175-function discover_pingback_server_uri($url, $deprecated = '') {
176-       if ( !empty($deprecated) )
177-               _deprecated_argument(__FUNCTION__, 'deprecated', '0.0');
178+function discover_pingback_server_uri( $url, $deprecated = '' ) {
179+       if ( !empty( $deprecated ) )
180+               _deprecated_argument( __FUNCTION__, '0.0' );
181 
182        $pingback_str_dquote = 'rel="pingback"';
183        $pingback_str_squote = 'rel=\'pingback\'';
184Index: wp-includes/cron.php
185===================================================================
186--- wp-includes/cron.php        (revision 12538)
187+++ wp-includes/cron.php        (working copy)
188@@ -136,7 +136,7 @@
189        // Backward compatibility
190        // Previously this function took the arguments as discrete vars rather than an array like the rest of the API
191        if ( !is_array($args) ) {
192-               _deprecated_argument(__FUNCTION__, 'args', '3.0.0', __('This argument has changed to an array so as to match with the behaviour of all the other cron functions.') );
193+               _deprecated_argument( __FUNCTION__, '3.0.0', __('This argument has changed to an array to match the behavior of the other cron functions.') );
194                $args = array_slice( func_get_args(), 1 );
195        }
196 
197Index: wp-includes/formatting.php
198===================================================================
199--- wp-includes/formatting.php  (revision 12538)
200+++ wp-includes/formatting.php  (working copy)
201@@ -866,6 +866,9 @@
202  * @return string Converted string.
203  */
204 function convert_chars($content, $deprecated = '') {
205+       if ( !empty( $deprecated ) )
206+               _deprecated_argument( __FUNCTION__, '0.0' );
207+
208        // Translation of invalid Unicode references range to valid range
209        $wp_htmltranswinuni = array(
210        '&#128;' => '&#8364;', // the Euro sign
211Index: wp-includes/functions.php
212===================================================================
213--- wp-includes/functions.php   (revision 12538)
214+++ wp-includes/functions.php   (working copy)
215@@ -570,6 +570,9 @@
216  * @return null returns when finished.
217  */
218 function add_option( $name, $value = '', $deprecated = '', $autoload = 'yes' ) {
219+       if ( !empty( $deprecated ) )
220+               _deprecated_argument( __FUNCTION__, '2.3' );
221+
222        global $wpdb;
223 
224        wp_protect_special_option( $name );
225@@ -1188,6 +1191,9 @@
226  * @return bool|string False on failure and string of headers if HEAD request.
227  */
228 function wp_get_http( $url, $file_path = false, $deprecated = false ) {
229+       if ( !empty( $deprecated ) )
230+               _deprecated_argument( __FUNCTION__, '0.0' );
231+
232        @set_time_limit( 60 );
233 
234        $options = array();
235@@ -1230,6 +1236,9 @@
236  * @return bool|string False on failure, headers on success.
237  */
238 function wp_get_http_headers( $url, $deprecated = false ) {
239+       if ( !empty( $deprecated ) )
240+               _deprecated_argument( __FUNCTION__, '0.0' );
241+
242        $response = wp_remote_head( $url );
243 
244        if ( is_wp_error( $response ) )
245@@ -2172,6 +2181,9 @@
246  * @return array
247  */
248 function wp_upload_bits( $name, $deprecated, $bits, $time = null ) {
249+       if ( !empty( $deprecated ) )
250+               _deprecated_argument( __FUNCTION__, '0.0' );
251+
252        if ( empty( $name ) )
253                return array( 'error' => __( 'Empty filename' ) );
254 
255@@ -3017,7 +3029,7 @@
256  * For example:
257  * <code>
258  * if ( !empty($deprecated) )
259- *     _deprecated_argument( __FUNCTION__, 'deprecated', '0.0' );
260+ *     _deprecated_argument( __FUNCTION__, '0.0' );
261  * </code>
262  *
263  * There is a hook deprecated_argument_run that will be called that can be used
264@@ -3031,24 +3043,23 @@
265  * @since 3.0.0
266  * @access private
267  *
268- * @uses do_action() Calls 'deprecated_argument_run' and passes the function and argument names and what to use instead.
269+ * @uses do_action() Calls 'deprecated_argument_run' and passes the function name and what to use instead.
270  * @uses apply_filters() Calls 'deprecated_argument_trigger_error' and expects boolean value of true to do trigger or false to not trigger error.
271  *
272  * @param string $function The function that was called
273- * @param string $argument The name of the deprecated argument that was used
274- * @param string $version The version of WordPress that deprecated the function
275+ * @param string $version The version of WordPress that deprecated the argument used
276  * @param string $message Optional. A message regarding the change.
277  */
278-function _deprecated_argument($function, $argument, $version, $message = null) {
279+function _deprecated_argument($function, $version, $message = null) {
280 
281-       do_action('deprecated_argument_run', $function, $argument, $message);
282+       do_action('deprecated_argument_run', $function, $message);
283 
284        // Allow plugin to filter the output error trigger
285        if( WP_DEBUG && apply_filters( 'deprecated_argument_trigger_error', true ) ) {
286                if( !is_null($message) )
287-                       trigger_error( sprintf( __('The %1$s argument of %2$s is <strong>deprecated</strong> since version %3$s! %4$s'), $function, $argument, $version, $message ) );
288+                       trigger_error( sprintf( __('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s'), $function, $version, $message ) );
289                else
290-                       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 ) );
291+                       trigger_error( sprintf( __('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $argument, $version ) );
292        }
293 }
294 
295Index: wp-includes/kses.php
296===================================================================
297--- wp-includes/kses.php        (revision 12538)
298+++ wp-includes/kses.php        (working copy)
299@@ -1197,6 +1197,9 @@
300 add_action('set_current_user', 'kses_init');
301 
302 function safecss_filter_attr( $css, $deprecated = '' ) {
303+       if ( !empty( $deprecated ) )
304+               _deprecated_argument( __FUNCTION__, '0.0' );
305+
306        $css = wp_kses_no_null($css);
307        $css = str_replace(array("\n","\r","\t"), '', $css);
308 
309Index: wp-includes/link-template.php
310===================================================================
311--- wp-includes/link-template.php       (revision 12538)
312+++ wp-includes/link-template.php       (working copy)
313@@ -168,7 +168,10 @@
314  * @param mixed $deprecated Not used.
315  * @return string
316  */
317-function post_permalink($post_id = 0, $deprecated = '') {
318+function post_permalink( $post_id = 0, $deprecated = '' ) {
319+       if ( !empty( $deprecated ) )
320+               _deprecated_argument( __FUNCTION__, '0.0' );
321+
322        return get_permalink($post_id);
323 }
324 
325Index: wp-includes/post-template.php
326===================================================================
327--- wp-includes/post-template.php       (revision 12538)
328+++ wp-includes/post-template.php       (working copy)
329@@ -245,9 +245,9 @@
330  * @param mixed $deprecated Not used.
331  * @return string
332  */
333-function get_the_excerpt($deprecated = '') {
334+function get_the_excerpt( $deprecated = '' ) {
335        if ( !empty( $deprecated ) )
336-               _deprecated_argument(__FUNCTION__, 'deprecated', '2.3');
337+               _deprecated_argument( __FUNCTION__, '2.3' );
338 
339        global $post;
340        $output = $post->post_excerpt;
341@@ -900,7 +900,10 @@
342  * @param bool $deprecated Deprecated. Not used.
343  * @param bool $permalink Optional, default is false. Whether to include permalink.
344  */
345-function the_attachment_link($id = 0, $fullsize = false, $deprecated = false, $permalink = false) {
346+function the_attachment_link( $id = 0, $fullsize = false, $deprecated = false, $permalink = false ) {
347+       if ( !empty( $deprecated ) )
348+               _deprecated_argument( __FUNCTION__, '0.0' );
349+
350        if ( $fullsize )
351                echo wp_get_attachment_link($id, 'full', $permalink);
352        else
353Index: wp-includes/post.php
354===================================================================
355--- wp-includes/post.php        (revision 12538)
356+++ wp-includes/post.php        (working copy)
357@@ -3538,9 +3538,11 @@
358  * @param int $deprecated Not Used. Can be set to null.
359  * @param object $post Object type containing the post information
360  */
361-function _future_post_hook($deprecated = '', $post) {
362+function _future_post_hook( $deprecated = '', $post ) {
363+       if ( !empty( $deprecated ) )
364+               _deprecated_argument( __FUNCTION__, '0.0' );
365        wp_clear_scheduled_hook( 'publish_future_post', array( $post->ID ) );
366-       wp_schedule_single_event(strtotime($post->post_date_gmt. ' GMT'), 'publish_future_post', array($post->ID));
367+       wp_schedule_single_event( strtotime( $post->post_date_gmt. ' GMT' ), 'publish_future_post', array( $post->ID ) );
368 }
369 
370 /**
371Index: wp-includes/widgets.php
372===================================================================
373--- wp-includes/widgets.php     (revision 12538)
374+++ wp-includes/widgets.php     (working copy)
375@@ -985,7 +985,7 @@
376  */
377 function wp_get_sidebars_widgets($deprecated = true) {
378        if ( $deprecated !== true )
379-               _deprecated_argument(__FUNCTION__, 'deprecated', '0.0');
380+               _deprecated_argument( __FUNCTION__, '0.0' );
381 
382        global $wp_registered_widgets, $wp_registered_sidebars, $_wp_sidebars_widgets;
383