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
- Combine multiple plugins into one?
- Security and .htaccess
- WP_query parameters for date range
- How would implement StackExchange ‘Questions with similar titles’ for the FAQ on my wordpress site
- Plugins error (Use roles and capabilities instead) on latest version, multisite
- What’s the point of using WordPress’s built in admin-ajax.php?
- WP Crowdfunding customization [closed]
- Get the url of the full sized attachment image using post ID?
- Getting Post details when post is published
- Post-terms-order PHP errors after update
- Do I still need a theme to use page builders?
- Duplicate Settings Plugin, Independent & Separate by Tab
- Call to a member function have_posts() on a non-object on normal loop
- Woo Commerce Variations [closed]
- wp_set_auth_cookie causes 403 error in the wooCommerce checkout
- Not able to add option in Sub-Menu under page
- wp_schedule_single_event not working: cron job is triggered but nothing gets executed
- add image crop function like in wp customizer
- WooCommerce Force Display of Base Country Order Addresses
- Plugin Activation Error – The plugin generated 22 characters of unexpected output during activation
- The add_action(‘register_form’) isn’t effecting my registration form
- WordPress Stats Plugin: Display Post Views [closed]
- Custom content plugin for front page in wordpress
- Share my WordPress plugin for updating how?
- How can I change page content for good once a button is pressed?
- ACF Taxonomy search on backend (Relationship field)
- Looking for a wordpress referral plugin that counts the referral after an action is performed [closed]
- How to call uninstall.php?
- Load css classes after using ajax calls
- Theme causing SSL break on chrome
- How to recognize which plugin generated this code?
- How to create a “plugin” or “block” that can manipulate WordPress DOM in frontend?