esc_textarea
shouldn’t strip out newlines — It’s just a thin wrapper around htmlspecialchars
: http://core.trac.wordpress.org/browser/tags/3.3.2/wp-includes/formatting.php#L2536
<?php
function esc_textarea( $text ) {
$safe_text = htmlspecialchars( $text, ENT_QUOTES );
return apply_filters( 'esc_textarea', $safe_text, $text );
}
That said, there are lots of options. What do you want your users to do have the ability to post? esc_html
will escape all special characters (just like esc_textarea
). esc_attr(strip_tags($stuff));
is a favorite combination of mine.
You should also have a look at the data validation page in the codex.
Related Posts:
- Sample code for validating custom metabox?
- How do I stop HTML entities in a custom meta box from being un-htmlentitied?
- Convert textarea with wp_editor
- Resetting admin post form on JS validation fail
- Stop saving process when metabox is invalid [duplicate]
- Passing error/warning messages from a meta box to “admin_notices”
- How to HIDE everything in PUBLISH metabox except Move to Trash & PUBLISH button
- Removing panels (meta boxes) in the Block Editor
- How can I create a taxonomy meta-box with search suggestions but no new terms input?
- How Does WordPress Remember Metabox Positions?
- How to Add Reminders/Notes to New Post Meta Boxes
- How to reorder meta box position?
- Custom Meta Boxes: multiple fields within a repeatable field
- Save checkbox value in metabox
- How to group meta boxes on the post edit page
- get registered metaboxes by post type or post ID
- Remove metabox from specific page template in admin
- Is there a filter/action to add content to WP admin metaboxes?
- Attach Files Metabox
- How do I create a meta box for dates?
- esc before saving or before displaying does it matter?
- Add a meta description to home page?
- how to sanitize checkbox input?
- Validation Function for URL in plugin
- Set height of the categories meta box in post dashboard
- Save checkboxes of a metabox with a foreach loop (invalid argument)
- Get image captions for images on gallery post format metabox
- Multiple Checkboxes Metabox
- Adding Metaboxes – so much code is there a shorter DRY way?
- I need a Simple image uploader with a simple screen. WP default has too many options.
- Show or hide custom meta box not work with Gutenberg
- TinyMCE with custom buttons on a meta box
- How do i hide the auto-generated custom field that’s created when update_post_meta() is called?
- How to search by metadata using REST API
- Display oembed in repeatable metaboxs using CMB2
- Undefined ‘post_type’ error on Add new page
- metabox wordpress show in frontend
- How to use get_post_custom function on the blog page?
- Multiplicate entry on update_post_meta
- Populate meta select box with child pages
- Problem with meta box in Links
- Post Meta not saving when have empty post
- How to modify Publish metabox?
- Hide Polylang metabox from the post edit sidebar
- Store multiple textarea data in database from a metabox
- Controlling Meta Box Height
- Is there a way to display metabox in frontend? How?
- Custom Meta box only returns most recent value on page
- Display Term Metabox Only On Certain Term Edit and Add Pages In Admin
- How to prevent further updates of custom meta when using actions to set one meta based on another
- how can i do metabox [closed]
- How to add meta box for image upload using WordPress media uploader?
- why add_menu_page use simple function as arg while add_meta_box a call back?
- Output from Meta Box Array
- How to show the value of specific key from nested array?
- Parse a text area custom meta box and assign as value to existing meta keys
- WordPress global variables?
- Getting metabox value?
- I have added a metabox and inside it i added a secondary title and a text editor but if i write anything it does not save it or show it on my page
- Hide Page Title with Post Meta
- How many meta-query fields support WordPress search at a time?
- Meta box does not save or update
- Adding metaboxes to attachment pages
- WP admin display custom field if another field value is “Female”
- Show button if meta box has content, else hide
- Post Excerpt field only showing for default administrator
- How to validation for sanitize_URL?
- Is ‘repeatable’ a field type for meta boxes?
- Checkbox in post not saving value
- Custom loop attached to link
- post meta – problem : copy the same meta for all the articles
- ACF – Hiding metaboxes through screen settings doesn’t work
- Remove Username and just show Name in Author Metabox in backend
- how can I make this metabox area
- get_post_meta giving errors while creating a metabox
- how to Add Meta Box with featured image settings and To Edit Post Screen For Inline Styles (css box)?
- Metabox not saving values
- Update Post Meta in Front End with a form
- Metabox with checkbox is not working true!
- Featured Gallery to custom post type
- Displaying a Metabox linked to post settings for all users
- Can’t get meta values to save
- Unable to save multiple images in wordpress
- Custom WP Meta Box – Use data from within the post screen inside meta box
- How Add a Save Button to Custom Meta Box without Leave/Stay js Dialog?
- How to show select_advanced content instead of ID?
- Error when adding Meta Boxes, but only when adding 3 with the same callback
- Using Meta Boxes in a Custom Page Template
- A correct hook for saving meta boxes data
- update_post_meta does not work
- Hooking into the Meta Boxes (Name/Web Address/Description) on the ‘Add New Link’ Page
- Custom carousel with meta box data
- when saveing $meta_box i get Undefined index error
- Adding a Custom ‘Now’ button under ‘Published on’ header to return current date and time
- Adding meta boxes to custom post type
- Meta boxes not showing up
- How do I create a Meta box that can be repeated? (with an image section and text area)
- How can i remove blank area caused by theme’s post meta boxes?
- Need help, Passing variables with get_post_meta
- How can I put a checkbox in the post editor