~katiekitty/+junk/wordpress-byet

« back to all changes in this revision

Viewing changes to wp-admin/plugin-editor.php

  • Committer: kserver
  • Date: 2010-05-15 01:16:36 UTC
  • Revision ID: kserver@kserver-desktop-20100515011636-mnr1j7t637suptdq
Wordpress 2.9.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
/** WordPress Administration Bootstrap */
10
10
require_once('admin.php');
11
11
 
 
12
if ( !current_user_can('edit_plugins') )
 
13
        wp_die('<p>'.__('You do not have sufficient permissions to edit plugins for this blog.').'</p>');
 
14
 
12
15
$title = __("Edit Plugins");
13
16
$parent_file = 'plugins.php';
14
17
 
19
22
$plugins = get_plugins();
20
23
 
21
24
if ( isset($_REQUEST['file']) )
22
 
        $plugin = $_REQUEST['file'];
 
25
        $plugin = stripslashes($_REQUEST['file']);
23
26
 
24
27
if ( empty($plugin) ) {
25
28
        $plugin = array_keys($plugins);
30
33
 
31
34
if ( empty($file) )
32
35
        $file = $plugin_files[0];
 
36
else
 
37
        $file = stripslashes($file);
33
38
 
34
39
$file = validate_file_to_edit($file, $plugin_files);
35
40
$real_file = WP_PLUGIN_DIR . '/' . $file;
 
41
$scrollto = isset($_REQUEST['scrollto']) ? (int) $_REQUEST['scrollto'] : 0;
36
42
 
37
43
switch ( $action ) {
38
44
 
40
46
 
41
47
        check_admin_referer('edit-plugin_' . $file);
42
48
 
43
 
        if ( !current_user_can('edit_plugins') )
44
 
                wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this blog.').'</p>');
45
 
 
46
49
        $newcontent = stripslashes($_POST['newcontent']);
47
50
        if ( is_writeable($real_file) ) {
48
51
                $f = fopen($real_file, 'w+');
53
56
                if ( is_plugin_active($file) || isset($_POST['phperror']) ) {
54
57
                        if ( is_plugin_active($file) )
55
58
                                deactivate_plugins($file, true);
56
 
                        wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&liveupdate=1"));
 
59
                        wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&liveupdate=1&scrollto=$scrollto"));
57
60
                        exit;
58
61
                }
59
 
                wp_redirect("plugin-editor.php?file=$file&a=te");
 
62
                wp_redirect("plugin-editor.php?file=$file&a=te&scrollto=$scrollto");
60
63
        } else {
61
 
                wp_redirect("plugin-editor.php?file=$file");
 
64
                wp_redirect("plugin-editor.php?file=$file&scrollto=$scrollto");
62
65
        }
63
66
        exit;
64
67
 
66
69
 
67
70
default:
68
71
 
69
 
        if ( !current_user_can('edit_plugins') )
70
 
                wp_die('<p>'.__('You do not have sufficient permissions to edit plugins for this blog.').'</p>');
71
 
 
72
72
        if ( isset($_GET['liveupdate']) ) {
73
73
                check_admin_referer('edit-plugin-test_' . $file);
74
74
 
79
79
                if ( ! is_plugin_active($file) )
80
80
                        activate_plugin($file, "plugin-editor.php?file=$file&phperror=1"); // we'll override this later if the plugin can be included without fatal error
81
81
 
82
 
                wp_redirect("plugin-editor.php?file=$file&a=te");
 
82
                wp_redirect("plugin-editor.php?file=$file&a=te&scrollto=$scrollto");
83
83
                exit;
84
84
        }
85
85
 
202
202
                <input type="hidden" name="action" value="update" />
203
203
                <input type="hidden" name="file" value="<?php echo esc_attr($file) ?>" />
204
204
                <input type="hidden" name="plugin" value="<?php echo esc_attr($plugin) ?>" />
 
205
                <input type="hidden" name="scrollto" id="scrollto" value="<?php echo $scrollto; ?>" />
205
206
                </div>
206
207
                <?php if ( !empty( $docs_select ) ) : ?>
207
208
                <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>
224
225
</form>
225
226
<br class="clear" />
226
227
</div>
 
228
<script type="text/javascript">
 
229
/* <![CDATA[ */
 
230
jQuery(document).ready(function($){
 
231
        $('#template').submit(function(){ $('#scrollto').val( $('#newcontent').scrollTop() ); });
 
232
        $('#newcontent').scrollTop( $('#scrollto').val() );
 
233
});
 
234
/* ]]> */
 
235
</script>
227
236
<?php
228
237
        break;
229
238
}