WordPress.org

Make WordPress Core

Ticket #11969: theme-editor.2.diff

File theme-editor.2.diff, 2.9 KB (added by scribu, 4 years ago)

use add_query_arg()

  • wp-admin/theme-editor.php

     
    3131        wp_die(__('The requested theme does not exist.')); 
    3232 
    3333$allowed_files = array_merge($themes[$theme]['Stylesheet Files'], $themes[$theme]['Template Files']); 
    34  
     34$requestedfile = $file; 
    3535if (empty($file)) { 
    3636        $file = $allowed_files[0]; 
    3737} else { 
     
    5555 
    5656        $newcontent = stripslashes($_POST['newcontent']); 
    5757        $theme = urlencode($theme); 
     58         
     59        $location = add_query_arg(array('file' => $requestedfile, 'theme' => $theme, 'scrollto' => $scrollto, 'dir' => $dir ), admin_url('theme-editor.php')); 
     60 
    5861        if (is_writeable($file)) { 
    5962                //is_writable() not always reliable, check return value. see comments @ http://uk.php.net/is_writable 
    6063                $f = fopen($file, 'w+'); 
    6164                if ($f !== FALSE) { 
    6265                        fwrite($f, $newcontent); 
    6366                        fclose($f); 
    64                         $location = "theme-editor.php?file=$file&theme=$theme&a=te&scrollto=$scrollto"; 
    65                 } else { 
    66                         $location = "theme-editor.php?file=$file&theme=$theme&scrollto=$scrollto"; 
     67                        $location = add_query_arg('a', 'te', $location); 
    6768                } 
    68         } else { 
    69                 $location = "theme-editor.php?file=$file&theme=$theme&scrollto=$scrollto"; 
    7069        } 
    7170 
    7271        $location = wp_kses_no_null($location); 
     
    169168        ksort( $template_mapping ); 
    170169        while ( list( $template_sorted_key, list( $template_file, $filedesc ) ) = each( $template_mapping ) ) : 
    171170        ?> 
    172                 <li><a href="theme-editor.php?file=<?php echo "$template_file"; ?>&amp;theme=<?php echo urlencode($theme) ?>&amp;dir=theme"><?php echo $filedesc ?></a></li> 
     171                <li><a href="<?php echo add_query_arg( array('file' => $template_file, 'theme' => urlencode($theme), 'dir' => 'theme'), admin_url('theme-editor.php') ); ?>"><?php echo $filedesc ?></a></li> 
    173172<?php endwhile; ?> 
    174173        </ul> 
    175174        <h3><?php /* translators: Theme stylesheets in theme editor */ echo _x('Styles', 'Theme stylesheets in theme editor'); ?></h3> 
     
    197196        <?php wp_nonce_field('edit-theme_' . $file . $theme) ?> 
    198197                 <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1" class="codepress <?php echo $codepress_lang ?>"><?php echo $content ?></textarea> 
    199198                 <input type="hidden" name="action" value="update" /> 
    200                  <input type="hidden" name="file" value="<?php echo esc_attr($file) ?>" /> 
     199                 <input type="hidden" name="file" value="<?php echo esc_attr($requestedfile) ?>" /> 
     200                 <input type="hidden" name="dir" value="<?php echo esc_attr($dir) ?>" /> 
    201201                 <input type="hidden" name="theme" value="<?php echo esc_attr($theme) ?>" /> 
    202202                 <input type="hidden" name="scrollto" id="scrollto" value="<?php echo $scrollto; ?>" /> 
    203203                 </div> 
    204         <?php if ( isset($functions ) && count($functions) ) { ?> 
     204        <?php if ( !empty($functions) ) { ?> 
    205205                <div id="documentation"> 
    206206                <label for="docs-list"><?php _e('Documentation:') ?></label> 
    207207                <?php echo $docs_select; ?>