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]
- echo value from ‘select’ field type into page template using cmb2?
- How can I show drafts in wp_dropdown_pages list?
- How can I save repeatable fields with one value inside an array?
- Validation Function for URL in plugin
- Creating Custom Meta Boxes on Plugin Option Page
- How to get custom field image url of specific size
- Best Way to Remove WordPress Meta Box based on Post Status
- Advanced Custom Fields query
- Datepicker not supporting timepicker
- Plugin “Meta Box”: Implementing meta boxes in custom post type
- How to create Repeater fields using Advanced Custom Fields?
- Plugin allowing for artists, events and venues
- Admin Dashboard with Custom Tab for Client
- Plugin not saving values when placed in a folder within /wp-content/plugins
- Woocommerce with metabox plugin
- WordPress CMB2 – Run function on save
- RW Meta Box ,Problem setting post title
- dynamically generating plugin syntax
- Carbon Fields use in custom plugin class
- How I can get custom field’s current value?
- UnWanted Custom field added in the wp page edit area
- Woocommerce – How to populate custom select field with stored values on checkout page?
- get_post_type on post.php
- Save / Show multi line text in metabox
- Assign / update custom field value for all posts (How can I assign only to posts without custom field value?)
- Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
- How to toggle between two custom fields in WordPress woocommerce ‘WC Product Field Group’ plugin?
- How can I make my metabox appear?
- Custom User meta field display
- Retrieving Meta from Image Attachment
- 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
- Finding the screen id of a page generated with add_menu_page
- Date format – Meta Box plugin
- 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
- Access post title from custom meta box on title change
- 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?
- How to add an extra, independent set of custom fields?
- How can I store data from custom fields to custom tables?
- 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
- Dictionary-style definition list plugin
- Advanced Custom Fields Plugin – Images not displaying
- Adding custom Field To The Posts Listing
- Error Metabox Warning: call_user_func() expects parameter 1 to be a valid callback
- What snippet do I need to type to show my ACF field show up on my theme?
- Is there a way to make [Table Of Content] plugin while not using revision data?
- Help with autofilling field
- Register PODS Custom Field with WPGraphQL [closed]
- WordPress default post categories meta box widget
- 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
- Add Cancel Button to a Custom Meta Box
- 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
- How can I call functions from a custom plugin?
- Problem with conditional woocommerce custom checkout field
- My own metabox checkbox plugin only saves the last value I’ve checked
- CMB2 Post Search Field displays/repeats initial post if left empty
- Need help getting a certain value out of a multi dimensional array
- Change post template the proper way
- Creating a user ‘add custom field’ section
- Displaying image from a repeatable group
- Metabox Data not saving
- What method should I use for a sidebar widget that reads latest posts?
- Problem for recover and save metaboxes
- force category table refresh when adding new category
- Extending a CPT by Created by another plugin
- ACF: Hide a div or template section when a custom field (in a field group) is empty
- How ACF Advanced Custom Field works with Woocommerce Single Product [closed]
- How do I add custom fields to the “Edit page” admin screen?
- Displaying Random Image from ACF Options Page [closed]
- Need help saving input fields for Security Deposit plugin in WC Vendors page
- Adding a variable to a meta field in the backend?
- ACF: Not displaying ACF data from another post
- Order shipped by which driver[hook for woocoomerce order staus changed and popup in admin panel ] [closed]
- Links not opening as they should. Custom WP plugin
- Meta box not displaying on the plugin page
- Order custom post type by posts with most likes first