On this page
wp_ajax_edit_theme_plugin_file()
Ajax handler for editing a theme or plugin file.
Description
See also
Source
File: wp-admin/includes/ajax-actions.php. View all references
function wp_ajax_edit_theme_plugin_file() {
$r = wp_edit_theme_plugin_file( wp_unslash( $_POST ) ); // Validation of args is done in wp_edit_theme_plugin_file().
if ( is_wp_error( $r ) ) {
wp_send_json_error(
array_merge(
array(
'code' => $r->get_error_code(),
'message' => $r->get_error_message(),
),
(array) $r->get_error_data()
)
);
} else {
wp_send_json_success(
array(
'message' => __( 'File edited successfully.' ),
)
);
}
}
Related
Uses
| Uses | Description |
|---|---|
| wp_edit_theme_plugin_file() wp-admin/includes/file.php | Attempts to edit a file for a theme or plugin. |
| __() wp-includes/l10n.php | Retrieves the translation of $text. |
| wp_unslash() wp-includes/formatting.php | Removes slashes from a string or recursively removes slashes from strings within an array. |
| wp_send_json_error() wp-includes/functions.php | Sends a JSON response back to an Ajax request, indicating failure. |
| wp_send_json_success() wp-includes/functions.php | Sends a JSON response back to an Ajax request, indicating success. |
| is_wp_error() wp-includes/load.php | Checks whether the given variable is a WordPress Error. |
Changelog
| Version | Description |
|---|---|
| 4.9.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_ajax_edit_theme_plugin_file