Replacing mysql_escape_string in a custom plugin when moving to PHP7

You don’t need to sanitize the variables that are passed to wp_update_post() because wp_update_post() after some checks pass the data to wp_insert_post() and wp_insert_post() calls sanitize_post(), which does the sanitization of all arguments. Also add_post_meta and update_post_meta also do all the sanitization for you. To answer your question I would replace mysql_escape_string with $wpdb->esc_sql($_POST[$value]). It … Read more

WordPress + JavaScipt + AJAX + MySQL: insert query for form

I’ve cleaned everything a little bit. Now it looks like that: ajax.js function ajaxSubmit(e){ var nazwa_szkolenia = document.getElementById(“nazwa_szkolenia”).value; var Data_szkolenia = document.getElementById(“Data_szkolenia”).value; var Godzina = document.getElementById(“Godzina”).value; var Max_pacjent = document.getElementById(“Max_pacjent”).value; var dataString = []; dataString[‘nazwa_szkolenia1’] = nazwa_szkolenia; dataString[‘Data_szkolenia1’] = Data_szkolenia; dataString[‘Godzina1’] = Godzina; dataString[‘Max_pacjent1’] = Max_pacjent; if (nazwa_szkolenia == ” || Data_szkolenia == ” || … Read more