mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-05 05:04:31 +00:00
Add documentation lookup shortcuts to Theme and Plugin Editors. Props beaulebens. fixes #9184
git-svn-id: https://develop.svn.wordpress.org/trunk@10607 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -238,4 +238,38 @@ function show_message($message) {
|
||||
echo "<p>$message</p>\n";
|
||||
}
|
||||
|
||||
function wp_doc_link_parse( $content ) {
|
||||
if ( !is_string( $content ) || empty( $content ) )
|
||||
return array();
|
||||
|
||||
$tokens = token_get_all( $content );
|
||||
$functions = array();
|
||||
$ignore_functions = array();
|
||||
for ( $t = 0, $count = count( $tokens ); $t < $count; $t++ ) {
|
||||
if ( !is_array( $tokens[$t] ) ) continue;
|
||||
if ( T_STRING == $tokens[$t][0] && ( '(' == $tokens[ $t + 1 ] || '(' == $tokens[ $t + 2 ] ) ) {
|
||||
// If it's a function or class defined locally, there's not going to be any docs available
|
||||
if ( 'class' == $tokens[ $t - 2 ][1] || 'function' == $tokens[ $t - 2 ][1] || T_OBJECT_OPERATOR == $tokens[ $t - 1 ][0] ) {
|
||||
$ignore_functions[] = $tokens[$t][1];
|
||||
}
|
||||
// Add this to our stack of unique references
|
||||
$functions[] = $tokens[$t][1];
|
||||
}
|
||||
}
|
||||
|
||||
$functions = array_unique( $functions );
|
||||
sort( $functions );
|
||||
$ignore_functions = apply_filters( 'documentation_ignore_functions', $ignore_functions );
|
||||
$ignore_functions = array_unique( $ignore_functions );
|
||||
|
||||
$out = array();
|
||||
foreach ( $functions as $function ) {
|
||||
if ( in_array( $function, $ignore_functions ) )
|
||||
continue;
|
||||
$out[] = $function;
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user