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 … -> “Use “SYSTEM”, to retrieve data from the System (like a parameter, a server configuration or constant)”

…and this… -> “[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?



, , , Sascha Koeth 4 years 2020-05-30T16:11:14-05:00 0 Answers 95 views 0

Leave an answer