Make WordPress Core


Ignore:
Timestamp:
05/06/2009 04:08:13 AM (15 years ago)
Author:
ryan
Message:

Die on file error. Cleanup. Props hakre. fixes #9452

File:
1 edited

Legend:

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

    r11204 r11214  
    8585
    8686    wp_enqueue_script( 'codepress' );
    87     add_action( 'admin_print_footer_scripts', 'codepress_footer_js' );
    88     require_once('admin-header.php');
    89 
    90     update_recently_edited(WP_PLUGIN_DIR . '/' . $file);
    91 
     87    add_action( 'admin_print_footer_scripts', 'codepress_footer_js' ); 
     88   
    9289    // List of allowable extensions
    9390    $editable_extensions = array('php', 'txt', 'text', 'js', 'css', 'html', 'htm', 'xml', 'inc', 'include');
    94     $extra_extensions = apply_filters('editable_extensions', null);
    95     if ( is_array($extra_extensions) )
    96         $editable_extensions = array_merge($editable_extensions, $extra_extensions);
     91    $editable_extensions = (array) apply_filters('editable_extensions', $editable_extensions);
    9792
    9893    if ( ! is_file($real_file) ) {
    99         $error = __('No such file exists! Double check the name and try again.');
     94        wp_die(sprintf('<p>%s</p>', __('No such file exists! Double check the name and try again.')));
    10095    } else {
    10196        // Get the extension of the file
     
    10499            // If extension is not in the acceptable list, skip it
    105100            if ( !in_array( $ext, $editable_extensions) )
    106                 $error = __('Files of this type are not editable.');
     101                wp_die(sprintf('<p>%s</p>', __('Files of this type are not editable.')));
    107102        }
    108103    }
    109 
    110     if ( ! $error ) {
    111         $content = file_get_contents( $real_file );
    112 
    113         if ( '.php' == substr( $real_file, strrpos( $real_file, '.' ) ) ) {
    114             $functions = wp_doc_link_parse( $content );
    115 
    116             $docs_select = '<select name="docs-list" id="docs-list">';
    117             $docs_select .= '<option value="">' . __( 'Function Name...' ) . '</option>';
    118             foreach ( $functions as $function) {
    119                 $docs_select .= '<option value="' . esc_attr( $function ) . '">' . htmlspecialchars( $function ) . '()</option>';
    120             }
    121             $docs_select .= '</select>';
     104   
     105    require_once('admin-header.php');
     106   
     107    update_recently_edited(WP_PLUGIN_DIR . '/' . $file);
     108
     109    $content = file_get_contents( $real_file );
     110
     111    if ( '.php' == substr( $real_file, strrpos( $real_file, '.' ) ) ) {
     112        $functions = wp_doc_link_parse( $content );
     113
     114        $docs_select = '<select name="docs-list" id="docs-list">';
     115        $docs_select .= '<option value="">' . __( 'Function Name...' ) . '</option>';
     116        foreach ( $functions as $function) {
     117            $docs_select .= '<option value="' . esc_attr( $function ) . '">' . htmlspecialchars( $function ) . '()</option>';
    122118        }
    123 
    124         $content = htmlspecialchars( $content );
    125         $codepress_lang = codepress_get_lang($real_file);
    126     }
     119        $docs_select .= '</select>';
     120    }
     121
     122    $content = htmlspecialchars( $content );
     123    $codepress_lang = codepress_get_lang($real_file);
    127124
    128125    ?>
     
    142139<div class="bordertitle">
    143140    <form id="themeselector" action="plugin-editor.php" method="post">
    144         <strong><label for="theme"><?php _e('Select plugin to edit:'); ?> </label></strong>
     141        <strong><label for="plugin"><?php _e('Select plugin to edit:'); ?> </label></strong>
    145142        <select name="plugin" id="plugin">
    146143<?php
     
    196193    }
    197194?>
    198         <li<?php echo $file == $plugin_file ? ' class="highlight"' : ''; ?>><a href="plugin-editor.php?file=<?php echo $plugin_file; ?>&plugin=<?php echo $plugin; ?>"><?php echo $plugin_file ?></a></li>
     195        <li<?php echo $file == $plugin_file ? ' class="highlight"' : ''; ?>><a href="plugin-editor.php?file=<?php echo $plugin_file; ?>&amp;plugin=<?php echo $plugin; ?>"><?php echo $plugin_file ?></a></li>
    199196<?php endforeach; ?>
    200197    </ul>
    201198    </div>
    202 <?php   if ( ! $error ) { ?>
    203199    <form name="template" id="template" action="plugin-editor.php" method="post">
    204200    <?php wp_nonce_field('edit-plugin_' . $file) ?>
     
    209205        </div>
    210206        <?php if ( count( $functions ) ) : ?>
    211         <div id="documentation"><label for="docs-list"><?php _e('Documentation:') ?></label> <?php echo $docs_select ?> <input type="button" class="button" value="<?php esc_attr_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>
     207        <div id="documentation"><label for="docs-list"><?php _e('Documentation:') ?></label> <?php echo $docs_select ?> <input type="button" class="button" value="<?php esc_attr_e( 'Lookup' ) ?> " onclick="if ( '' != jQuery('#docs-list').val() ) { window.open( 'http://api.wordpress.org/core/handbook/1.0/?function=' + escape( jQuery( '#docs-list' ).val() ) + '&amp;locale=<?php echo urlencode( get_locale() ) ?>&amp;version=<?php echo urlencode( $wp_version ) ?>&amp;redirect=true'); }" /></div>
    212208        <?php endif; ?>
    213209<?php if ( is_writeable($real_file) ) : ?>
     
    227223<?php endif; ?>
    228224 </form>
    229 <?php
    230     } else {
    231         echo '<div class="error"><p>' . $error . '</p></div>';
    232     }
    233 ?>
    234225<div class="clear"> &nbsp; </div>
    235226</div>
Note: See TracChangeset for help on using the changeset viewer.