wp_slash( string|array $value )
Adds slashes to a string or recursively adds slashes to strings within an array.
Description
This should be used when preparing data for core API that expects slashed data. This should not be used to escape data going directly into an SQL query.
Parameters
- $value
-
(string|array) (Required) String or array of data to slash.
Return
(string|array) Slashed $value.
Source
File: wp-includes/formatting.php
function wp_slash( $value ) { if ( is_array( $value ) ) { $value = array_map( 'wp_slash', $value ); } if ( is_string( $value ) ) { return addslashes( $value ); } return $value; }
Related
Used By
Used By | Description |
---|---|
wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php: WP_REST_Widgets_Controller::save_widget() | Saves the widget in the request object. |
wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php: WP_REST_Templates_Controller::update_item() | Updates a single template. |
wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php: WP_REST_Templates_Controller::create_item() | Creates a single template. |
wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php: WP_REST_Application_Passwords_Controller::create_item() | Creates an application password. |
wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php: WP_REST_Application_Passwords_Controller::update_item() | Updates an application password. |
wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php: WP_REST_Attachments_Controller::edit_media_item() | Applies edits to a media item and creates a new attachment record. |
wp-includes/formatting.php: wp_rel_ugc() | Adds |
wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php: WP_REST_Attachments_Controller::insert_attachment() | Inserts the attachment post in the database. Does not update the attachment meta. |
wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php: WP_REST_Autosaves_Controller::create_item() | Creates, updates or deletes an autosave revision. |
wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php: WP_REST_Autosaves_Controller::create_post_autosave() | Creates autosave for the specified post. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::save_changeset_post() | Save the post for the loaded changeset. |
wp-includes/theme.php: wp_update_custom_css_post() | Updates the |
wp-includes/rest-api/fields/class-wp-rest-meta-fields.php: WP_REST_Meta_Fields::delete_meta_value() | Deletes a meta value for an object. |
wp-includes/rest-api/fields/class-wp-rest-meta-fields.php: WP_REST_Meta_Fields::update_multi_meta_value() | Updates multiple meta values for an object. |
wp-includes/rest-api/fields/class-wp-rest-meta-fields.php: WP_REST_Meta_Fields::update_meta_value() | Updates a meta value for an object. |
wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php: WP_REST_Users_Controller::create_item() | Creates a single user. |
wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php: WP_REST_Users_Controller::update_item() | Updates a single user. |
wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php: WP_REST_Terms_Controller::create_item() | Creates a single term in a taxonomy. |
wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php: WP_REST_Terms_Controller::update_item() | Updates a single term from a taxonomy. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::create_item() | Creates a single post. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::update_item() | Updates a single post. |
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php: WP_REST_Comments_Controller::update_item() | Updates a comment. |
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php: WP_REST_Comments_Controller::create_item() | Creates a comment. |
wp-includes/class-wp-customize-nav-menus.php: WP_Customize_Nav_Menus::save_nav_menus_created_posts() | Publish the auto-draft posts that were created for nav menu items. |
wp-includes/class-wp-customize-nav-menus.php: WP_Customize_Nav_Menus::insert_auto_draft_post() | Add a new |
wp-includes/comment.php: wp_handle_comment_submission() | Handles the submission of a comment, usually posted to wp-comments-post.php via a comment form. |
wp-includes/customize/class-wp-customize-nav-menu-setting.php: WP_Customize_Nav_Menu_Setting::update() | Create/update the nav_menu term for this setting. |
wp-includes/customize/class-wp-customize-nav-menu-item-setting.php: WP_Customize_Nav_Menu_Item_Setting::sanitize() | Sanitize an input. |
wp-includes/customize/class-wp-customize-nav-menu-item-setting.php: WP_Customize_Nav_Menu_Item_Setting::update() | Creates/updates the nav_menu_item post for this setting. |
wp-admin/includes/taxonomy.php: wp_update_category() | Aliases wp_insert_category() with minimal args. |
wp-admin/includes/user.php: edit_user() | Edit user settings based on contents of $_POST |
wp-admin/includes/media.php: media_upload_form_handler() | Handles form submissions for the legacy media uploader. |
wp-admin/includes/post.php: wp_autosave() | Save a post submitted with XHR |
wp-admin/includes/post.php: add_meta() | Add post meta data defined in $_POST superglobal for post with given ID. |
wp-admin/includes/post.php: edit_post() | Update an existing post with values provided in $_POST. |
wp-admin/includes/ajax-actions.php: wp_ajax_save_attachment() | Ajax handler for updating attachment attributes. |
wp-admin/includes/ajax-actions.php: wp_ajax_inline_save() | Ajax handler for Quick Edit saving a post from a list table. |
wp-admin/includes/ajax-actions.php: wp_ajax_replyto_comment() | Ajax handler for replying to a comment. |
wp-admin/includes/bookmark.php: wp_update_link() | Updates a link in the database. |
wp-includes/formatting.php: addslashes_gpc() | Adds slashes to escape strings. |
wp-includes/formatting.php: wp_rel_nofollow() | Adds |
wp-includes/class-wp-embed.php: WP_Embed::shortcode() | The do_shortcode() callback function. |
wp-includes/taxonomy.php: wp_update_term() | Update term based on arguments provided. |
wp-includes/user.php: wp_create_user() | A simpler way of inserting a user into the database. |
wp-includes/post.php: wp_update_post() | Update a post with new post data. |
wp-includes/revision.php: _wp_put_post_revision() | Inserts post data into the posts table as a post revision. |
wp-includes/revision.php: wp_restore_post_revision() | Restores a post to the specified revision. |
wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::escape() | Escape string or array of strings for database. |
wp-includes/class-wp-customize-widgets.php: WP_Customize_Widgets::call_widget_update() | Finds and invokes the widget update and control callbacks. |
wp-includes/comment.php: wp_update_comment() | Updates an existing comment in the database. |
Changelog
Version | Description |
---|---|
5.5.0 | Non-string values are left untouched. |
3.6.0 | Introduced. |
© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_slash