admin管理员组

文章数量:1122846

I want to add a product programmatically using a wordpress plugin but programmatically as entering it manually is a hassle. I have a little bit of programming experience.

I found this: What is your best practice to execute one-time scripts?

The only issue that I'm having is how do I call functions from a plugin in this script? I guess more specifically, what is the base path of plugin .php files that I would pass in to include() ? An example would be great.

I want to add a product programmatically using a wordpress plugin but programmatically as entering it manually is a hassle. I have a little bit of programming experience.

I found this: What is your best practice to execute one-time scripts?

The only issue that I'm having is how do I call functions from a plugin in this script? I guess more specifically, what is the base path of plugin .php files that I would pass in to include() ? An example would be great.

Share Improve this question edited Apr 13, 2017 at 12:37 CommunityBot 1 asked Jun 1, 2015 at 20:32 UserNotDefinedUserNotDefined 101
Add a comment  | 

1 Answer 1

Reset to default 0

I would lean toward the approaches by babixeddu, Amit Sukapure, or tf from the question you referenced. As WordPress loads normally with those solutions you can use Core functions to manipulate data. In your case, you'd need plugin_dir_path()

In my case, I have a very simple plugin that creates an admin page with a single "execute" button on it. I hack in the code, upload the plugin, login, and click. That method prevents accidentally running the code multiple times. I can then remove the plugin.

本文标签: woocommerce offtopicRun onetime script calling plugin functions