2016-08-30 4 views
1

Nach Migration auf neue AWS-Instanz und Verschieben von Apache zu Nginx habe ich ein Problem mit wp_kses, die ich vorher nicht hatte.wp_kses fehlen zwei Argumente Problem

Die Form einreicht und die gesamte Verarbeitung gut geht, sondern zum Erfolg Seite der Umleitung Ich erhalte eine Fehlermeldung wie folgt aus:

Warning: Missing argument 2 für wp_kses(), genannt in path/to/a/file.php auf der Leitung 20 und in root/Ordner/public_html/wp-includes definiert/kses.php on line 521

Diese für die Verarbeitung Form mein Code

//Template Name: Jobs: Add mini ad form process 

if (!wp_verify_nonce($_POST['ad_mini_add_nonce'], 'submit_add_mini_ad_form')) : 

    echo 'Sorry your nonce didn\'t verify'; 
    exit; 

endif; 

    // Checking for secret filed 
    if (isset($_POST["secret_field"]) && !empty($_POST["secret_field"])) : 

     echo 'Sorry, could not send.'; 
     exit; 

    endif; 

     // process form data 
     $position_name   = wp_kses($_POST['position_name']); 
     $company_name   = wp_kses($_POST['company_name']); 
     $location    = wp_kses($_POST['location']); 
     $link_for_apply   = wp_kses($_POST['link_for_apply']); 
     $website    = wp_kses($_POST['website']); 
     $name     = wp_kses($_POST['name']); 
     $email     = wp_kses($_POST['email']); 
     $phone     = wp_kses($_POST['phone']); 


     // Create new add - privately published 
     $new_ad = array(
      'post_title'  => $position_name, 
      'post_type'  => 'post', 
      'post_status'  => 'private', 
      'post_author'  => 1001189, //Tanja Mladenovic 
     ); 
     $new_ad_id = wp_insert_post($new_ad); 
     $new_ad_url = get_post_permalink($new_ad_id); 
     $next_month   = date('Ymd', strtotime('+30 days', time())); 
     // Fill custom fileds 
     add_post_meta($new_ad_id, 'company_location', $location); 
     add_post_meta($new_ad_id, 'ad_type', 'mini'); 
     add_post_meta($new_ad_id, 'company_name', $company_name); 
     add_post_meta($new_ad_id, 'webiste', $webiste); 
     add_post_meta($new_ad_id, 'expire', $next_month); 
     add_post_meta($new_ad_id, 'contact_person_name', $name); 
     add_post_meta($new_ad_id, 'contact_person_phone', $phone); 
     add_post_meta($new_ad_id, 'contact_person_email', $email); 
     add_post_meta($new_ad_id, 'type_of_apply', 'link'); 
     add_post_meta($new_ad_id, 'link_for_apply', $link); 

ich weiß wp_kses kann habe noch zwei arg aber alles funktionierte ohne Probleme. Offizielle Dokumentation sagt, dass wp_kses zweites Argument ‚allowed_html‘ Standardwert von keinem hat (und das ist genau das, was ich will), und die dritte Argument ‚allowed_protocols‘

Antwort

2

Ok optional ist, wurde mir klar, was das Problem. Es war WordPress Update. In dieser neueren Version muss wp_kses zweites Argument haben. Im meinem Fall, ich will nicht, html ermöglichen, so dass ich hinzugefügt leeres Array, und es funktioniert

Also änderte ich diesen Teil:

$position_name   = wp_kses($_POST['position_name']); 
$company_name   = wp_kses($_POST['company_name']); 
$location    = wp_kses($_POST['location']); 
$link_for_apply   = wp_kses($_POST['link_for_apply']); 
$website    = wp_kses($_POST['website']); 
$name     = wp_kses($_POST['name']); 
$email     = wp_kses($_POST['email']); 
$phone     = wp_kses($_POST['phone']); 

dazu:

$position_name   = wp_kses($_POST['position_name'], array()); 
$company_name   = wp_kses($_POST['company_name'], array()); 
$location    = wp_kses($_POST['location'], array()); 
$link_for_apply   = wp_kses($_POST['link_for_apply'], array()); 
$website    = wp_kses($_POST['website'], array()); 
$name     = wp_kses($_POST['name'], array()); 
$email     = wp_kses($_POST['email'], array()); 
$phone     = wp_kses($_POST['phone'], array()); 
Verwandte Themen