Question on sanitizing register_setting input
-
I’m trying to make a theme options page, it is working, but
I’m not sure on how to sanitize the input properly.There is a checkbox that lets users choose wether to display a twitter link and icon in the header, and then there is a text field where they put the twitter link.
I am sanitizing the checkbox by intval only,
register_setting( 'Pia-settings-group', 'Pia_twitter_option','intval' ); /*icon and link in header*/
as in this example;
https://codex.www.ads-software.com/Function_Reference/register_setting
Is this correct?But how do I sanitize the twitter url?
I need to make sure that is not empty and that it is a proper twitter link, and if it isnt, it has to reset the checkbox aswell, or an icon but no link will be dispalyed in the theme.I have read
https://www.chipbennett.net/2011/02/17/incorporating-the-settings-api-in-wordpress-themes/
and
https://ottopress.com/2009/wordpress-settings-api-tutorial/and alot of url validation / preg_match tips, but I can’t put it together.
It’s not do or die but i’d like to learn.
- The topic ‘Question on sanitizing register_setting input’ is closed to new replies.