Once validated, you just need to update the post meta with the form input:
if ( url_allowed( $_POST['video-url'] ) ) {
update_post_meta( $post_id, 'video-url', esc_url( $_POST['video-url'] ) );
} else {
//if user edits entry to remove a url from input, it will be deleted
delete_post_meta( $post_id, 'video-url' );
}
If you look at the source of esc_url(), you can see it is using wp_allowed_protocols and wp_kses_normalize_entities().
Side Note:
It is also parsing the url with wp_parse_url(), a wrapper for php’s parse_url(), to check the different parts. Not unlike what we did in the url_allowed() function (in fact I’ll update that answer to use wp_parse_url() if you want).
Related Posts:
- How to add meta box to plugin admin page?
- Add custom meta box on Post page
- Validation Function for URL in plugin
- Creating Custom Meta Boxes on Plugin Option Page
- How to attach Links into page/post or custom post type?
- Add custom buttons with custom actions in Edit Post screen in WordPress?
- Best Way to Remove WordPress Meta Box based on Post Status
- Plugin “Meta Box”: Implementing meta boxes in custom post type
- How WordPress autosave can save plugin fields?
- How can I filter the contents of a metafield before it’s displayed in the admin?
- Admin Dashboard with Custom Tab for Client
- Security checking in meta_box save is reluctant?
- Advanced Custom Fields
- RW Meta Box ,Problem setting post title
- dynamically generating plugin syntax
- Correct way to make meta box with more than one meta field secure
- get_post_type on post.php
- All of my custom posttypes are 404’ing
- Save / Show multi line text in metabox
- PHP basics help in WP context – remove a class/function?
- How to remove plugin metaboxes from edit.php
- How can I make my metabox appear?
- How to inform the user that the save was not successful?
- Show meta box only when post is being published first time
- Retrieving Meta from Image Attachment
- WordPress metaboxes – textfield suggestion automatically populated
- Why are my queries interfering with the global post variable?
- 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 custom meta boxes to specified custom post type
- Access post title from custom meta box on title change
- Inserting Plugins Into Blank Space of Externally Designed WordPress Theme
- add_meta_box creating default form field types
- Should meta boxes for specific pages be save in their own plugins?
- WordPress meta-box and checkbox-list
- Error Metabox Warning: call_user_func() expects parameter 1 to be a valid callback
- Custom Meta box change size
- Preset custom fields
- submit two file input fields in the same form
- WordPress default post categories meta box widget
- How to get checkbox by default true in metabox?
- How to pass multiple custom fields as shortcode’s parameters
- CMB2 Output Select Box Chosen Option
- Add Cancel Button to a Custom Meta Box
- WordPress CPT Url metabox collection
- Add_Meta_box to custom page (formidable edit post)
- why my wordpress dont have toolbar like, plugin, themes and other?
- My own metabox checkbox plugin only saves the last value I’ve checked
- CMB2 Post Search Field displays/repeats initial post if left empty
- Do something with thumbnail image on post publish
- How can I remove this sidebar from my Search Results page?
- Add custom field for users
- Alter add_meta_box
- Displaying image from a repeatable group
- How to add jquery to my custom post type wp plugin
- How to get rid of error message of custom metabox in dashboard when moving out of edit page?
- Metabox Data not saving
- Custom plugin breaks css.php on Multisite
- Advanced Custom Field User Help URL
- Problem for recover and save metaboxes
- How can i do custom author list?
- Meta Box plugin image_advanced not showing up on frontend
- How to change data format in custom meta box field [closed]
- iframe not showing on frontend when using a CMB2 field
- Problems with file_exists() with metabox plugin in WordPress
- Meta box not displaying on the plugin page
- add_meta_box showing blank screen in my page
- Remove WordPress Toolbar buttons
- Adding an admin page – OOP approach not working
- How can I pass a variable to wp_ajax action?
- How do I make images clickable so as to enlarge them using lightbox?
- FacetWP group listings by custom field [closed]
- UnInstallation of a Plugin from a developers perspective – The correct and clean method
- Change wordpress current_time function to different timezone
- wp_trash_post is leaking memory
- Error “preg_match_all” with WordPress SEO by Yoast plugin [closed]
- Plugins Page invisible / white
- Inserting external image in WordPress plugin to track the plugin instalation [closed]
- WordPress + PHP + IIS + PHP Fatal error: require():
- Programatically update non-wordpress repository hosted (self-hosted) plugins
- options creation for plugins
- Users are being redirected to main site when trying to register on subsite of my Multisite network
- How to disable a widget when dependent plugin is inactive?
- First plugin, problem with get_pages
- eLearning Module
- Export postmeta (custom fields)
- Google Maps with categories
- WordPress Cache delete on plugin uninstall
- How to create repeater field manually, without plugin (ACF Pro)?
- Should I use the action in the plugin’s main file?
- Woocommerce checkout page broken when set as a checkout in woocommerce settings [closed]
- Ajax Call not Working in Plugin
- Store GravityForm data in phpmyadmin (mysql)
- How to remove WordPress Default Comment? not Facebook
- plugin operation launch every time i click on page
- Related post based on 2 categories
- How to markup wordpress site using Schema.org?
- Password Protected Directory Link Shows Maintenance Mode Page
- How do I increase the 255 character limit on the ‘description’ field for link library links?