X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/wordpress.git/blobdiff_plain/d3b1ea255664edd2deef17f900a655613d20820d..8f374b7233bc2815ccc387e448d208c5434eb961:/wp-admin/plugin-editor.php diff --git a/wp-admin/plugin-editor.php b/wp-admin/plugin-editor.php index e297ef4c..b7758d22 100644 --- a/wp-admin/plugin-editor.php +++ b/wp-admin/plugin-editor.php @@ -7,19 +7,28 @@ */ /** WordPress Administration Bootstrap */ -require_once('admin.php'); +require_once('./admin.php'); + +if ( is_multisite() && ! is_network_admin() ) { + wp_redirect( network_admin_url( 'plugin-editor.php' ) ); + exit(); +} + +if ( !current_user_can('edit_plugins') ) + wp_die( __('You do not have sufficient permissions to edit plugins for this site.') ); $title = __("Edit Plugins"); $parent_file = 'plugins.php'; wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file', 'plugin')); -wp_admin_css( 'theme-editor' ); - $plugins = get_plugins(); +if ( empty($plugins) ) + wp_die( __('There are no plugins installed on this site.') ); + if ( isset($_REQUEST['file']) ) - $plugin = $_REQUEST['file']; + $plugin = stripslashes($_REQUEST['file']); if ( empty($plugin) ) { $plugin = array_keys($plugins); @@ -30,9 +39,12 @@ $plugin_files = get_plugin_files($plugin); if ( empty($file) ) $file = $plugin_files[0]; +else + $file = stripslashes($file); $file = validate_file_to_edit($file, $plugin_files); $real_file = WP_PLUGIN_DIR . '/' . $file; +$scrollto = isset($_REQUEST['scrollto']) ? (int) $_REQUEST['scrollto'] : 0; switch ( $action ) { @@ -40,25 +52,28 @@ case 'update': check_admin_referer('edit-plugin_' . $file); - if ( !current_user_can('edit_plugins') ) - wp_die('
'.__('You do not have sufficient permissions to edit templates for this blog.').'
'); - $newcontent = stripslashes($_POST['newcontent']); if ( is_writeable($real_file) ) { $f = fopen($real_file, 'w+'); fwrite($f, $newcontent); fclose($f); + $network_wide = is_plugin_active_for_network( $file ); + // Deactivate so we can test it. if ( is_plugin_active($file) || isset($_POST['phperror']) ) { if ( is_plugin_active($file) ) deactivate_plugins($file, true); - wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&liveupdate=1")); + + if ( ! is_network_admin() ) + update_option( 'recently_activated', array( $file => time() ) + (array) get_option( 'recently_activated' ) ); + + wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&liveupdate=1&scrollto=$scrollto&networkwide=" . $network_wide)); exit; } - wp_redirect("plugin-editor.php?file=$file&a=te"); + wp_redirect( self_admin_url("plugin-editor.php?file=$file&a=te&scrollto=$scrollto") ); } else { - wp_redirect("plugin-editor.php?file=$file"); + wp_redirect( self_admin_url("plugin-editor.php?file=$file&scrollto=$scrollto") ); } exit; @@ -66,9 +81,6 @@ break; default: - if ( !current_user_can('edit_plugins') ) - wp_die(''.__('You do not have sufficient permissions to edit plugins for this blog.').'
'); - if ( isset($_GET['liveupdate']) ) { check_admin_referer('edit-plugin-test_' . $file); @@ -76,16 +88,13 @@ default: if ( is_wp_error($error) ) wp_die( $error ); - if ( ! is_plugin_active($file) ) - activate_plugin($file, "plugin-editor.php?file=$file&phperror=1"); // we'll override this later if the plugin can be included without fatal error + if ( ( ! empty( $_GET['networkwide'] ) && ! is_plugin_active_for_network($file) ) || ! is_plugin_active($file) ) + activate_plugin($file, "plugin-editor.php?file=$file&phperror=1", ! empty( $_GET['networkwide'] ) ); // we'll override this later if the plugin can be included without fatal error - wp_redirect("plugin-editor.php?file=$file&a=te"); + wp_redirect( self_admin_url("plugin-editor.php?file=$file&a=te&scrollto=$scrollto") ); exit; } - if ( use_codepress() ) - wp_enqueue_script( 'codepress' ); - // List of allowable extensions $editable_extensions = array('php', 'txt', 'text', 'js', 'css', 'html', 'htm', 'xml', 'inc', 'include'); $editable_extensions = (array) apply_filters('editable_extensions', $editable_extensions); @@ -102,7 +111,25 @@ default: } } - require_once('admin-header.php'); + get_current_screen()->add_help_tab( array( + 'id' => 'overview', + 'title' => __('Overview'), + 'content' => + '' . __('You can use the editor to make changes to any of your plugins’ individual PHP files. Be aware that if you make changes, plugins updates will overwrite your customizations.') . '
' . + '' . __('Choose a plugin to edit from the menu in the upper right and click the Select button. Click once on any file name to load it in the editor, and make your changes. Don’t forget to save your changes (Update File) when you’re finished.') . '
' . + '' . __('The Documentation menu below the editor lists the PHP functions recognized in the plugin file. Clicking Lookup takes you to a web page about that particular function.') . '
' . + '' . __('If you want to make changes but don’t want them to be overwritten when the plugin is updated, you may be ready to think about writing your own plugin. For information on how to edit plugins, write your own from scratch, or just better understand their anatomy, check out the links below.') . '
' . + ( is_network_admin() ? '' . __('Any edits to files from this screen will be reflected on all sites in the network.') . '
' : '' ) + ) ); + + get_current_screen()->set_help_sidebar( + '' . __('For more information:') . '
' . + '' . __('Documentation on Editing Plugins') . '
' . + '' . __('Documentation on Writing Plugins') . '
' . + '' . __('Support Forums') . '
' + ); + + require_once(ABSPATH . 'wp-admin/admin-header.php'); update_recently_edited(WP_PLUGIN_DIR . '/' . $file); @@ -111,22 +138,22 @@ default: if ( '.php' == substr( $real_file, strrpos( $real_file, '.' ) ) ) { $functions = wp_doc_link_parse( $content ); - $docs_select = ''; } - $content = htmlspecialchars( $content ); - $codepress_lang = codepress_get_lang($real_file); - + $content = esc_textarea( $content ); ?> -fatal error.') ?>
+fatal error.') ?>
@@ -136,8 +163,25 @@ default: