Passing browser infos to the wordpress function.php as a $_GET
I need to pass current/live browser information (like browser width) using javascript/jQuery to the wordpress function.php using the $_GET array/variable/filter/container method. Once the browser width data is in the $_GET “container” it should get a variable name. This named variable´s data value will then be pulled by a “token”-script using this syntax: [system:get:my_query_var]
– // print the variable stored inside $_GET // .
So it´s these steps:
Reading client browser data with javascript/jQuery like for example ->
my_variable_name = $(window).innerWidth()
then define functions.php $_GET variable and read data from javascript variable like for example ->
echo $_GET['my_variable_name'];
And then the “token”-Script is pulling the data with [system:get:my_variable_name]
. Which is a plugin script. So I don´t want to change that.
If I understand this …
https://docs.dynamic.ooo/article/116-dynamic-tags-token -> “Use “SYSTEM”, to retrieve data from the System (like a parameter, a server configuration or constant)”
…and this…
https://docs.dynamic.ooo/article/25-tokens -> “[system:get:my_query_var]
– print the variable stored inside $_GET, also compatible with POST, SESSION, COOKIE and SERVER systems vars;”
…correctly: the [system:get:my_variable_name] shortcode/token is looking into the function.php file to get the variable.
So my questions are:
- What is the easiest way and correct syntax to get this running within the wordpress environment using the example situation of looking for the browser width?
- Do I write all code into the function.php or do I need to create a seperate script document or use another existing one?
Thanks
Sascha
Leave an answer