Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method/action/filter to initialize fields #22

Open
tripflex opened this issue Oct 17, 2018 · 4 comments
Open

Add method/action/filter to initialize fields #22

tripflex opened this issue Oct 17, 2018 · 4 comments

Comments

@tripflex
Copy link

tripflex commented Oct 17, 2018

While I know this may not be a huge issue, currently the way addons work, I have to add my fields on every page load through the addon. As we all know with how over-saturated the plugin ecosystem is, users end up having a very large number of plugins activated on their site, eating up memory and adding load time, when a lot of the time it may not be necessary.

Would be nice if there way some way to either call a specific method, action, or filter, to trigger only when $this->fields in the RapidAddon are actually required (as to not have to constantly initialize the fields).

Reason being is in my addon i'm working on, I am dynamically creating the fields that are shown based on existing posts, configurations, etc ... which results in multiple WP_Query calls, option calls, etc

While I know this doesn't add any major load time to a site, most users will end up leaving WP All Import and my addon enabled on their site ... even after they are done importing.

Just wondering what your thoughts are on this? I know I could cache them in a transient or what not, but figure that shouldn't be necessary if we can figure out a way to initialize fields only when they are required

Was thinking maybe in the meantime could just check if user is admin, or on admin area page ... but haven't tried it out yet. Maybe i'm over analyzing it, but being a net/sys admin for so many years i've seen how many user's sites become so slow ... really just due to plugins running code that is not necessary, so I always try to minimize anytime that my codebase is ran

@joeguilmette
Copy link
Member

This is a valid concern, we should do everything we can to make sure that the add-ons only load when necessary. We'll see if we can address this next time we do a round of updates on the add-on API.

Thank you!

@tripflex
Copy link
Author

@joeguilmette awesome thanks for the response, just for reference here's the addon I created for WP Job Manager Field Editor:

https://github.com/tripflex/wp-job-manager-field-editor-import

@joeguilmette
Copy link
Member

Awesome - we'll add that to our add-ons page. Thank you!

@tripflex
Copy link
Author

@joeguilmette any update on this? Still seems overkill to be running code on every page load when it's not necessary, I feel like there should be some kind of check to see if we're actually on a WP All Import page (or if WP All Import transaction is running)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants