2

I'm working on front end submission and of course I want to secure data by filtering before inserting to database.

The form contains repeatable fields group data which I want filter by wp_kses function (external urls, etc.) but it would be great if user will be able to insert internal link to another publication and wp_kses will pass it..

I've managed this way:

$r_step_description = $_POST['step_description'];
            $allowed_html = array(
            'br' => array(),
            'em' => array(),
            'strong' => array(),
            'p' => array(),
            'br' => array()
        );
        $allowed_a = array(
            'a' => array(
                'href' => true
            ));
    for ($i = 0; $i < $count; $i++) {
        $domain = strpos($recipe_step_description[$i],'site-name.com');

    if(!empty($domain)){
             $allowed_html = array_merge($allowed_html, $allowed_a);}
             $r_steps['steps']['text'][$i] .= wp_kses(wpautop($r_step_description[$i]),$allowed_html);
        }

Everything ok with this except one thing. When second link to external domain is present - this link will be unfiltered.

Any clue?

Thank you in advance!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.