How to escape $_GET and check if isset?

The proper way to do that is using filter_input(). Here is an example for using a custom sanitize function: $tab = filter_input( INPUT_GET, ‘tab’, FILTER_CALLBACK, [‘options’ => ‘esc_html’] ); $tab = $tab ?: ‘front_page_options’;

wordpress is adding a second backslash when I use addslashes

In your code json_encode() function causes to add second backslash on the following line. $data = json_encode($item_data); Add the following code in place of above code so it will replace double backslashes with single backslash in data returned by json_encode function. $data = str_replace(“\\\'”,”\\'”,json_encode($item_data )); Visit following links for more information on json_encode function. json_encode … Read more

What’s the proper way to sanitize checkbox value sent to the database

I would use the filter_var() function. It has some predefined filters that you can use depending on what kind of data you are expecting such as string, number, etc. So to sanitize for a number: $sanitizedNum = filter_var($yourVar, FILTER_SANITIZE_NUMBER_INT); For a string you would just change “_NUM_INT” to “_STRING”. Wrap those in a custom function … Read more

Escaping date string in url with wordpress

strtotime will return false if you give it weird information. echo strtotime(“<script>’); // bool(false) However, if you do what you are doing and nest two statement you may not get what you expect. echo strtotime(‘+1 day’,strtotime(‘<script>’)); // int(86400) And date returns the beginning of the universe, the day of creation– January 1, 1970– if given … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)