R
R
Ruslan Amerkhanov2018-01-09 16:29:43
WordPress
Ruslan Amerkhanov, 2018-01-09 16:29:43

How can I force the handler function to change the global variable?

There are a number of functions that, by means of the same function, process the variables given to them. That is, a handler function is built into each of these functions. The problem is that the handler function, taking a variable as a parameter, changes it but does not pass it to the parent function. So the changes are not saved. If the variable is not passed as a parameter, but set as a global one, then everything will work, but the handler function will lose its universality, and you will have to multiply it and copy-paste it in each parent function, which is not good. How all the same to force the built-in function handler to transfer changes of variables? Sample code below:

a = 1
b = 1
c = 1


def a_changer(a):
    changer(a)
    print(a)
    return a


def b_changer(b):
    changer(b)
    print(b)
    return b


def c_changer(c):
    changer(c)
    print(c)
    return c


def changer(subject):
    subject = 2
    print(subject)
    return subject

a_changer(a)
b_changer(b)
c_changer(c)
print(a)
print(b)
print(c)

that is, the task is to print the variables a,b,c as 2 and not as 1 at the output

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Orkhan Hasanli, 2019-10-28
@azerphoenix

Hello!
I can't give you a specific answer because you didn't provide any source code.
To solve your problem, follow the following principles:
1) figure out exactly how this button is displayed. If this is output by the WP, then whether this functionality is part of the plugin or the theme itself. It could also be that the search button is driven by some theme customization framework or rendered as a widget. Knowing what you're working with will make it clear how to move or edit it.
2) Using css to move an icon from one block to another without changing the layout structure will not work. Unless you set this icon to position absolute and position it for different screen sizes. Solution, so-so...
3) You can not go deep into PHP, do the following ...
take another icon, add it to the place you need, look at the search triggers at the js level and add them to the new icon, and hide the current icon visually through display none. The option is also working.
In general, everything is individual ... you need to understand

A
Artem Sovetnikov, 2018-01-09
@Sovetnikov

Integer in Python is immutable ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question