X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/wordpress.git/blobdiff_plain/9c40b4d36daed9e28e48a5fe9205c32557195a4b..HEAD:/wp-admin/plugin-editor.php diff --git a/wp-admin/plugin-editor.php b/wp-admin/plugin-editor.php index e297ef4c..ab8968db 100644 --- a/wp-admin/plugin-editor.php +++ b/wp-admin/plugin-editor.php @@ -7,23 +7,50 @@ */ /** WordPress Administration Bootstrap */ -require_once('admin.php'); +require_once( dirname( __FILE__ ) . '/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( __('Sorry, you are not allowed 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')); +$plugins = get_plugins(); -wp_admin_css( 'theme-editor' ); +if ( empty( $plugins ) ) { + include( ABSPATH . 'wp-admin/admin-header.php' ); + ?> +
'.__('You do not have sufficient permissions to edit plugins for this blog.').'
'); +} else { if ( isset($_GET['liveupdate']) ) { check_admin_referer('edit-plugin-test_' . $file); - $error = validate_plugin($file); - if ( is_wp_error($error) ) + $error = validate_plugin( $plugin ); + + 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( $plugin, "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&plugin=$plugin&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); + + /** + * Filters file type extensions editable in the plugin editor. + * + * @since 2.8.0 + * + * @param array $editable_extensions An array of editable plugin file extensions. + */ + $editable_extensions = (array) apply_filters( 'editable_extensions', $editable_extensions ); if ( ! is_file($real_file) ) { wp_die(sprintf('%s
', __('No such file exists! Double check the name and try again.'))); @@ -102,7 +138,26 @@ 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 dropdown menu 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 Look Up takes you to a web page about that particular function.') . '
' . + '' . __( 'In the editing area the Tab key enters a tab character. To move below this area by pressing Tab, press the Esc key followed by the Tab key. In some cases the Esc key will need to be pressed twice before the Tab key will allow you to continue.' ) . '
' . + '' . __('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,33 +166,61 @@ 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.') ?>
- + if ( wp_verify_nonce( $_GET['_error_nonce'], 'plugin-activation-error_' . $file ) ) { + $iframe_url = add_query_arg( array( + 'action' => 'error_scrape', + 'plugin' => urlencode( $file ), + '_wpnonce' => urlencode( $_GET['_error_nonce'] ), + ), admin_url( 'plugins.php' ) ); + ?> +