Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
wp-admin-20241221212557
/
network
:
plugin-editor.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php /** * Edit plugin file editor administration panel. * * @package WordPress * @subpackage Administration */ /** WordPress Administration Bootstrap */ require_once __DIR__ . '/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.' ) ); } // Used in the HTML title tag. $title = __( 'Edit Plugins' ); $parent_file = 'plugins.php'; $plugins = get_plugins(); if ( empty( $plugins ) ) { require_once ABSPATH . 'wp-admin/admin-header.php'; ?> <div class="wrap"> <h1><?php echo esc_html( $title ); ?></h1> <?php wp_admin_notice( __( 'No plugins are currently available.' ), array( 'id' => 'message', 'additional_classes' => array( 'error' ), ) ); ?> </div> <?php require_once ABSPATH . 'wp-admin/admin-footer.php'; exit; } $file = ''; $plugin = ''; if ( isset( $_REQUEST['file'] ) ) { $file = wp_unslash( $_REQUEST['file'] ); } if ( isset( $_REQUEST['plugin'] ) ) { $plugin = wp_unslash( $_REQUEST['plugin'] ); } if ( empty( $plugin ) ) { if ( $file ) { // Locate the plugin for a given plugin file being edited. $file_dirname = dirname( $file ); foreach ( array_keys( $plugins ) as $plugin_candidate ) { if ( $plugin_candidate === $file || ( '.' !== $file_dirname && dirname( $plugin_candidate ) === $file_dirname ) ) { $plugin = $plugin_candidate; break; } } // Fallback to the file as the plugin. if ( empty( $plugin ) ) { $plugin = $file; } } else { $plugin = array_keys( $plugins ); $plugin = $plugin[0]; } } $plugin_files = get_plugin_files( $plugin ); if ( empty( $file ) ) { $file = $plugin_files[0]; } $file = validate_file_to_edit( $file, $plugin_files ); $real_file = WP_PLUGIN_DIR . '/' . $file; // Handle fallback editing of file when JavaScript is not available. $edit_error = null; $posted_content = null; if ( 'POST' === $_SERVER['REQUEST_METHOD'] ) { $r = wp_edit_theme_plugin_file( wp_unslash( $_POST ) ); if ( is_wp_error( $r ) ) { $edit_error = $r; if ( check_ajax_referer( 'edit-plugin_' . $file, 'nonce', false ) && isset( $_POST['newcontent'] ) ) { $posted_content = wp_unslash( $_POST['newcontent'] ); } } else { wp_redirect( add_query_arg( array( 'a' => 1, // This means "success" for some reason. 'plugin' => $plugin, 'file' => $file, ), admin_url( 'plugin-editor.php' ) ) ); exit; } } // List of allowable extensions. $editable_extensions = wp_get_plugin_file_editable_extensions( $plugin ); if ( ! is_file( $real_file ) ) { wp_die( sprintf( '<p>%s</p>', __( 'File does not exist! Please double check the name and try again.' ) ) ); } else { // Get the extension of the file. if ( preg_match( '/\.([^.]+)$/', $real_file, $matches ) ) { $ext = strtolower( $matches[1] ); // If extension is not in the acceptable list, skip it. if ( ! in_array( $ext, $editable_extensions, true ) ) { wp_die( sprintf( '<p>%s</p>', __( 'Files of this type are not editable.' ) ) ); } } } get_current_screen()->add_help_tab( array( 'id' => 'overview', 'title' => __( 'Overview' ), 'content' => '<p>' . __( 'You can use the plugin file 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.' ) . '</p>' . '<p>' . __( '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. Do not forget to save your changes (Update File) when you are finished.' ) . '</p>' . '<p>' . __( '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.' ) . '</p>' . '<p id="editor-keyboard-trap-help-1">' . __( 'When using a keyboard to navigate:' ) . '</p>' . '<ul>' .