Make WordPress Core


Ignore:
Timestamp:
11/17/2004 03:15:44 AM (22 years ago)
Author:
rboren
Message:

Theme, plugin, and file editing cleanup. Work in progress.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-functions.php

    r1829 r1858  
    730730}
    731731
     732
     733function validate_file_to_edit($file, $allowed_files = '') {
     734    if ('..' == substr($file,0,2))
     735        die (__('Sorry, can’t edit files with ".." in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.'));
     736   
     737    if (':' == substr($file,1,1))
     738        die (__('Sorry, can’t call files with their real path.'));
     739
     740    if ( !empty($allowed_files) && (! in_array($file, $allowed_files)) ) {
     741        die (__('Sorry, that file cannot be edited.'));
     742    }
     743   
     744    $file = stripslashes($file);
     745
     746    return $file;
     747}
     748
     749function get_real_file_to_edit($file) {
     750    $home = get_settings('home');
     751    if (($home != '')
     752            && ($home != get_settings('siteurl')) &&
     753            ('index.php' == $file || get_settings('blogfilename') == $file ||
     754             '.htaccess' == $file)) {
     755        $home_root = parse_url($home);
     756        $home_root = $home_root['path'];
     757        $root = str_replace($_SERVER["PHP_SELF"], '', $_SERVER["PATH_TRANSLATED"]);
     758        $home_root = $root . $home_root;
     759        $real_file = $home_root . '/' . $file;
     760    } else {
     761        $real_file = ABSPATH . $file;
     762    }
     763
     764    return $real_file;
     765}
     766
     767$wp_file_descriptions = array('index.php' => __('Main Template'),
     768                                                            'wp-layout.css' => __('Stylesheet'),
     769                                                            'style.css' => __('Stylesheet'),
     770                                                            'wp-comments.php' => __('Comments Template'),
     771                                                            'comments.php' => __('Comments Template'),
     772                                                            'wp-comments-popup.php' => __('Popup Comments Template'),
     773                                                            'comments-popup.php' => __('Popup Comments Template'),
     774                                                            'wp-footer.php' => __('Footer Template'),
     775                                                            'footer.php' => __('Footer Template'),
     776                                                            'wp-header.php' => __('Header Template'),
     777                                                            'header.php' => __('Header Template'),
     778                                                            'wp-sidebar.php' => __('Sidebar Template'),
     779                                                            'sidebar.php' => __('Sidebar Template'),
     780                                                            'archive.php' => __('Archive Template'),
     781                                                            'category.php' => __('Category Template'),
     782                                                            'page.php' => __('Page Template'),
     783                                                            'search.php' => __('Search Template'),
     784                                                            'single.php' => __('Post Template'),
     785                                                            '404.php' => __('404 Template'),
     786                                                            'my-hacks.php' => __('my-hacks.php (legacy hacks support)'),
     787                                                           
     788                                                            '.htaccess' => __('.htaccess (for rewrite rules)')
     789                                                            );
     790
     791function get_file_description($file) {
     792    global $wp_file_descriptions;
     793
     794    if (isset($wp_file_descriptions[$file])) {
     795        return $wp_file_descriptions[$file];
     796    }
     797
     798    return $file;
     799}
     800
     801function update_recently_edited($file) {
     802    $oldfiles = (array) get_option('recently_edited');
     803    if ($oldfiles) {
     804        $oldfiles = array_reverse($oldfiles);
     805        $oldfiles[] = $file;
     806        $oldfiles = array_reverse($oldfiles);
     807        $oldfiles = array_unique($oldfiles);
     808        if ( 5 < count($oldfiles) )
     809            array_pop($oldfiles);
     810    } else {
     811        $oldfiles[] = $file;
     812    }
     813    update_option('recently_edited', $oldfiles);
     814}
     815
    732816?>
Note: See TracChangeset for help on using the changeset viewer.