diff --git a/wp-admin/css/theme-editor.css b/wp-admin/css/theme-editor.css index 486f5c1925..2f938d84fe 100644 --- a/wp-admin/css/theme-editor.css +++ b/wp-admin/css/theme-editor.css @@ -64,3 +64,12 @@ div.bordertitle h2 { div.tablenav { margin-right: 210px; } + +#documentation { + margin-top: 10px; +} +#documentation label { + line-height: 22px; + vertical-align: top; + font-weight: bold; +} \ No newline at end of file diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php index ffb849704d..f5c15df4cc 100644 --- a/wp-admin/includes/misc.php +++ b/wp-admin/includes/misc.php @@ -238,4 +238,38 @@ function show_message($message) { echo "

$message

\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; +} + ?> diff --git a/wp-admin/plugin-editor.php b/wp-admin/plugin-editor.php index b807de895b..9e34ff457a 100644 --- a/wp-admin/plugin-editor.php +++ b/wp-admin/plugin-editor.php @@ -81,8 +81,22 @@ default: if ( ! is_file($real_file) ) $error = 1; - if ( ! $error ) - $content = htmlspecialchars(file_get_contents($real_file)); + if ( ! $error ) { + $content = file_get_contents( $real_file ); + + if ( 'php' == mb_substr( $real_file, mb_strrpos( $real_file, '.' ) + 1 ) ) { + $functions = wp_doc_link_parse( $content ); + + $docs_select = ''; + } + + $content = htmlspecialchars( $content ); + } ?> @@ -124,7 +138,7 @@ default:

@@ -135,6 +149,9 @@ default: + +
+

Warning: Making changes to active plugins is not recommended. If your changes cause a fatal error, the plugin will be automatically deactivated.'); ?>

diff --git a/wp-admin/theme-editor.php b/wp-admin/theme-editor.php index 361f26b61c..c455768624 100644 --- a/wp-admin/theme-editor.php +++ b/wp-admin/theme-editor.php @@ -87,7 +87,19 @@ default: if (!$error && filesize($real_file) > 0) { $f = fopen($real_file, 'r'); $content = fread($f, filesize($real_file)); - $content = htmlspecialchars($content); + + if ( 'php' == mb_substr( $real_file, mb_strrpos( $real_file, '.' ) + 1 ) ) { + $functions = wp_doc_link_parse( $content ); + + $docs_select = ''; + } + + $content = htmlspecialchars( $content ); } ?> @@ -187,6 +199,9 @@ if ($allowed_files) : + +
+