Make WordPress Core


Ignore:
Timestamp:
02/20/2009 08:00:09 PM (18 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/theme-editor.php

    r10194 r10607  
    8888                $f = fopen($real_file, 'r');
    8989                $content = fread($f, filesize($real_file));
    90                 $content = htmlspecialchars($content);
     90
     91                if ( 'php' == mb_substr( $real_file, mb_strrpos( $real_file, '.' ) + 1 ) ) {
     92                        $functions = wp_doc_link_parse( $content );
     93                       
     94                        $docs_select = '<select name="docs-list" id="docs-list">';
     95                        $docs_select .= '<option value="">' . __( 'Function Name...' ) . '</option>';
     96                        foreach ( $functions as $function) {                                   
     97                                $docs_select .= '<option value="' . urlencode( $function ) . '">' . htmlspecialchars( $function ) . '()</option>';
     98                        }
     99                        $docs_select .= '</select>';
     100                }
     101
     102                $content = htmlspecialchars( $content );
    91103        }
    92104
    … …  
    188200                 <input type="hidden" name="theme" value="<?php echo $theme ?>" />
    189201                 </div>
     202                <?php if ( count( $functions ) ) : ?>
     203                <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>
     204                <?php endif; ?>
    190205
    191206                <div>
Note: See TracChangeset for help on using the changeset viewer.