What is the global $wp object used for?

In the wordpress documentation for Global Variables, I did not find information about the $wp global variable.

I found a plugin which declares the global $wp variable as follows:

public function login_form(){
   global $wp;
   ...
}

But this variable is never used inside the declared function, so I wonder what is going on.

The entire function can be found here (links to the exact line in the GitHub WordPress Frontend Profile plugin)

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

It contains the main instance of the WP class, which is primarily responsible for parsing the request URL and querying the appropriate posts, as well as sending headers and handling 404s. It can be used for things like getting the current request URL.

If it’s declared in a function but not used, it’s likely a mistake, or left over from a previous version of the function that did use it. You would need to ask the plugin developer why.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x