Where is wp load.php
So, basically the plugin author expects some requests to be made to the plugin file in which you found this code. Since the author wants to use WordPress functionality in this file, he invokes the wp-load. I personally prefer the second option, but like I said, including wp-load.
If there is still something, that you don't quite understand about that - post a comment here and I'll try to explain further. If you access a plugin file directly it doesn't mean that you have the whole WordPress environment and you are not able to use the native core functions unless you include wp-load.
From what I read they usually include wp-load in the plugins when database usage is needed, but this is a bad choice as it raises a lot of problems.
This will include wp-load. But, as you say, that should not be necessary as it is a plugin. Nevertheless, you don't explain where did you find the code in your question, because wp-load. Plugin pages in the admin area don't have to reload WP because it is already loaded, but front-end pages do have to load it.
In short, there are several reasons to include wp-load. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Wordpress wp-load. Asked 8 years, 11 months ago. Active 6 years, 3 months ago. Viewed 58k times. Improve this question. Asaf Asaf 1, 7 7 gold badges 33 33 silver badges 56 56 bronze badges. Add a comment. Active Oldest Votes. Yes, you've understood correctly. Improve this answer.
Nikola Ivanov Nikolov Nikola Ivanov Nikolov 4, 1 1 gold badge 24 24 silver badges 27 27 bronze badges. Great, detailed answer! Thank you so very much! Now as for Doesn't the fact that the plugin runs already means wp-load.
Not at all! Bainternet Bainternet 6 6 silver badges 18 18 bronze badges. Todua Isnt that trying to get it from the wp-content folder? Connect and share knowledge within a single location that is structured and easy to search. I have a plugin which calls a stand-alone php script myAjax.
However, I'd like a more bulletproof method of specifying the path to wp-load. Since the file is either inside plugin or theme folder, which are always located inside wp-content folder.. You can simply get the path of the file and trim everything starting from wp-content from it:. If you need to make sure the wp is not inside some wp-content folder who knows? I know this is an old question but wanted to add my own answer which I think might help some users trying to achieve the same thing.
My solution: is quite simple, and should work to retrieve the root of the wordpress installation. You can now retrieve this inside your script and parse it along with the AJAX call.
The below PHP snippet will enqueue your script. Now inside your ajax-handler. Another trick that some of you might not be aware of is that before including wp-load.
This will tell WordPress to just load the basics meaning you will lose a lot of WP core functions but it will speed up the loading time since it won't include all the required files for a regular WP instance. You will have a better understanding of what is happening under the hood. But this will depend on the WP version.
Also keep in mind that the wp-load. Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams?
Learn more. How to include wp-load. Ask Question. Asked 10 years, 3 months ago. Active 1 year, 8 months ago. Viewed 67k times. I need to place the following code into the myAjax. Improve this question.
0コメント