Next soft reject translation

  1. Scripts and styles should not be hardcoded anywhere in your theme or added any other way but with wp_enqueue_* hook and to be added from the functions file. This includes custom JS/CSS.

https://developer.wordpress.org/reference/functions/wp_add_inline_script/

Example(s) from your code and there are more:
header.php - http://envato.d.pr/1fEQx/4d9dOIgS

It’s funny because when I start making this blog WordPress was in version 4.4.2 and this function exist from 4.5.

But what should I do ? how send to JS variable from header ?

Anyone can help how add this scripts ?

It is hard to tell just from this snippet, but it seems you are implementing Ajax in a very odd way. Read this article
https://codex.wordpress.org/AJAX_in_Plugins

This also is wrong, I can’t use:


from what I understand. I have found something like this but it’s not for me as I need variable from header

Don’t really understand what do you mean. The link contains info how to do a ajax call correctly.

If you want to insert some JS vars, you can use wp_add_inline_script function.

Use wp_localize_script()

Thanks, wp_localize_script works.

Check out this: https://codex.wordpress.org/Function_Reference/wp_localize_script