Make WordPress Core


Ignore:
Timestamp:
02/20/2009 08:00:09 PM (16 years ago)
Author:
ryan
Message:

Add documentation lookup shortcuts to Theme and Plugin Editors. Props beaulebens. fixes #9184

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/plugin-editor.php

    r10150 r10607  
    8282        $error = 1;
    8383
    84     if ( ! $error )
    85         $content = htmlspecialchars(file_get_contents($real_file));
     84    if ( ! $error ) {
     85        $content = file_get_contents( $real_file );
     86       
     87        if ( 'php' == mb_substr( $real_file, mb_strrpos( $real_file, '.' ) + 1 ) ) {
     88            $functions = wp_doc_link_parse( $content );
     89           
     90            $docs_select = '<select name="docs-list" id="docs-list">';
     91            $docs_select .= '<option value="">' . __( 'Function Name...' ) . '</option>';
     92            foreach ( $functions as $function) {
     93                $docs_select .= '<option value="' . urlencode( $function ) . '">' . htmlspecialchars( $function ) . '()</option>';
     94            }
     95            $docs_select .= '</select>';
     96        }
     97       
     98        $content = htmlspecialchars( $content );
     99    }
    86100
    87101    ?>
     
    125139    <ul>
    126140<?php foreach($plugin_files as $plugin_file) : ?>
    127         <li><a href="plugin-editor.php?file=<?php echo $plugin_file; ?>"><?php echo $plugins[$plugin_file]['Name']; ?></a></li>
     141        <li<?php echo $file == $plugin_file ? ' class="highlight"' : ''; ?>><a href="plugin-editor.php?file=<?php echo $plugin_file; ?>"><?php echo $plugins[$plugin_file]['Name']; ?></a></li>
    128142<?php endforeach; ?>
    129143    </ul>
     
    136150        <input type="hidden" name="file" value="<?php echo $file ?>" />
    137151        </div>
     152        <?php if ( count( $functions ) ) : ?>
     153        <div id="documentation"><label for="docs-list">Documentation:</label> <?php echo $docs_select ?> <input type="button" class="button" value=" <?php _e( 'Lookup' ) ?> " onclick="if ( '' != jQuery('#docs-list').val() ) { window.open( 'http://api.wordpress.org/core/handbook/1.0/?function=' + escape( jQuery( '#docs-list' ).val() ) + '&locale=<?php echo urlencode( get_locale() ) ?>&version=<?php echo urlencode( $wp_version ) ?>&redirect=true'); }" /></div>
     154        <?php endif; ?>
    138155<?php if ( is_writeable($real_file) ) : ?>
    139156    <?php if ( in_array($file, (array) get_option('active_plugins')) ) { ?>
Note: See TracChangeset for help on using the changeset viewer.