-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfind-deprecated-wp-functions.php
54 lines (48 loc) · 1.2 KB
/
find-deprecated-wp-functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
if ( ! $argv )
{
die( "\n\n==============\nYou must provide an absolute path to wp-includes/deprecated.php as the first parameter\n================\n\n" );
}//end if
$deprecated_file = $argv[1];
$file = file( $deprecated_file );
$function_replace = array();
$seek_function = false;
$deprecated_function = null;
$good_function = null;
foreach ( $file as $line )
{
if ( ! $seek_function )
{
if ( preg_match( '/\@deprecated [Uu]se (.+)/', $line, $matches ) )
{
$seek_function = true;
$good_function = $matches[1];
}//end if
if ( preg_match( '/^function ([^\(]+)/', $line, $matches ) )
{
$function_replace[ $matches[1] ] = null;
$good_function = null;
}//end if
}//end if
else
{
if ( preg_match( '/function ([^\(]+)/', $line, $matches ) )
{
$seek_function = false;
$function_replace[ $matches[1] ] = $good_function;
$good_function = null;
}//end if
}//end else
}//end foreach
foreach ( $function_replace as $bad => $good )
{
$good = str_replace( '$', '\$', $good );
if ( $good )
{
echo "\"{$bad}\" => \"{$good}\",\n";
}//end if
else
{
echo "\"{$bad}\" => null,\n";
}//end else
}//end foreach