I have seen that CMB2 offers the possibility to create a custom escaping function with which the values are checked before they’re displayed. So I set the escape_cb
parameter in the metafield this way:
$cmb->add_field( array(
'name' => esc_html__( 'Text Area for Code', 'cmb2' ),
'id' => $prefix . 'textarea_code',
'type' => 'textarea_code',
'sanitization_cb' => 'my_sanitize_text_callback',
'escape_cb' => 'my_escape_text_callback'
) );
Then I created the callback function for escaping, in order to convert HTML entities to their corresponding characters:
function my_escape_text_callback( $value, $field_args, $field ) {
$escaped_value = html_entity_decode( $value, ENT_QUOTES );
return $escaped_value;
}
Now it works great and in the edit screen in the admin panel I visualize the readable text.
Related Posts:
- Add custom meta box on Post page
- How WordPress autosave can save plugin fields?
- Security checking in meta_box save is reluctant?
- WordPress metaboxes – textfield suggestion automatically populated
- Preset custom fields
- How to pass multiple custom fields as shortcode’s parameters
- Do something with thumbnail image on post publish
- Add custom field for users
- How can i do custom author list?
- How to change data format in custom meta box field [closed]
- How to remove plugin metaboxes from edit.php
- How can I make my metabox appear?
- How do I hide posts across all loops based on the value of a custom field?
- How to inform the user that the save was not successful?
- Custom User meta field display
- Show meta box only when post is being published first time
- Retrieving Meta from Image Attachment
- Execute js files doesn’t seem to work
- Char limit on custom blog-post form? [closed]
- Unable to select image using custom image field type
- Redirect to another page using contact form 7? [closed]
- Why are my queries interfering with the global post variable?
- Every new post/draft has a custom field variable “yst_is_cornerstone” showing
- Custom Post Type Fields
- How do I enforce users to fill a determined custom field using WyPiekacz?
- Finding the screen id of a page generated with add_menu_page
- Date format – Meta Box plugin
- Meta Box by Rilwis, Load metabox on all page templates EXCEPT the homepage
- Adding class to last list item? Not WP generated
- How to Resize the Custom Post Images?
- Amazon.com intergration with WordPress?
- Sticky option for custom post types without using custom fields or plugins
- Adding custom meta boxes to specified custom post type
- How do we update a custom file upload field with the Advanced Custom Field plugin?
- Order posts by meta key ( Using ACF )
- How to add fields in the WordPress editor?
- Access post title from custom meta box on title change
- WordPress function to add text warning on every pages [closed]
- Inserting Plugins Into Blank Space of Externally Designed WordPress Theme
- How can I modify a custom post type and custom page template for a child theme if all content seams to be handled by theme’s ‘native’ plugin?
- add_meta_box creating default form field types
- How to add an extra, independent set of custom fields?
- Should meta boxes for specific pages be save in their own plugins?
- Price comparison table based on Custom Post Type?
- Show related posts based of current ACF field name in a single page post (a loop within loop)
- How can I store data from custom fields to custom tables?
- Woocommerce – Change Variable Product Add to Cart to behave like external product using Custom Field (link) [closed]
- WordPress meta-box and checkbox-list
- Custom Fields for Page Edits
- “After file loaded” action
- Plugin that lets visitors Like a post (not facebook) and stores likes in custom meta?
- Parent Child Custom Fields with Advanced Custom Fields
- grab or load text on demand
- How can I add user profile fields to my mailpress mailout
- Dictionary-style definition list plugin
- Advanced Custom Fields Plugin – Images not displaying
- Adding custom Field To The Posts Listing
- How to create repeater field manually, without plugin (ACF Pro)?
- Error Metabox Warning: call_user_func() expects parameter 1 to be a valid callback
- Creating New Dynamic Fields for a Certificate (Number Generation, Code Referencing, and more)
- WordPress Phone Field Check (use numbers, spaces and pluses)
- What snippet do I need to type to show my ACF field show up on my theme?
- Can export gallery but can’t import it Wp all import
- Is there a way to make [Table Of Content] plugin while not using revision data?
- Table of contents (TOC) plugin is not showing header tag
- Auto populate a user custom field from another user custom field
- Best approach to make all tags searchable by the wordpress search function
- Custom Meta box change size
- need to find duplicated meta value in custom filed and view the posts that have the same value
- Create a pdf from the entries in DB
- Help with autofilling field
- how to find out which plugin disable custom field for post
- What database state changes happen after a post is manually “updated” with no changes?
- submit two file input fields in the same form
- Register PODS Custom Field with WPGraphQL [closed]
- get_post_meta shortcode returns empty field
- WordPress default post categories meta box widget
- custom fields not displaying on wordpress site
- WordPress hide post from custom post-type on a single page
- Create multiple posts when a custom post is created
- Why Custom fields description is not working WordPress Version 5.4.2?
- Adding Custom Endpoint in WordPress Rest API
- General Term for this form Field
- How do I change the functionality of an image slider which is part of ACF?
- How to get checkbox by default true in metabox?
- Make custom post types using ACF
- Problem Advanced Custom Fields PRO
- Meta Key array building with multiple input values from fields
- CMB2 Output Select Box Chosen Option
- Get all user meta_keys and then group users by matching values
- Add Cancel Button to a Custom Meta Box
- Custom product page’s style for printing
- Custom plugin issue – Notice: Trying to get property of non-object in
- If I am not writing a theme, how do I add custom fields to a user for a plugin
- Simple Data picker meta box
- Taxonomy question
- WordPress CPT Url metabox collection
- How to get post that has non zero or greater than zero meta value
- Add_Meta_box to custom page (formidable edit post)
- How can I call functions from a custom plugin?