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

Where to put my own code? #565

Open
sintacs opened this issue Jul 8, 2021 · 5 comments
Open

Where to put my own code? #565

sintacs opened this issue Jul 8, 2021 · 5 comments

Comments

@sintacs
Copy link

sintacs commented Jul 8, 2021

Hello,

I installed the plugin and want to start adding my own code (class exists).
How do I start, where do I put the code?

Greetings
Dirk

@DevinVinson
Copy link
Owner

You can edit your own plugin however you want to and put the code wherever you want. I have a walk through on writing a plugin using the boilerplate here if you wanted to see a simplified usage: https://devinvinson.com/simple-login-style-plugin/

@sintacs
Copy link
Author

sintacs commented Jul 9, 2021

Thank you, but my plugin won't be this simple (simple in meaning including some js and/or css).
Let me explain: I have a existing class that I want to include in the WPPB but don't know where to put existing it or the code of it.
Should I copy the code into a existing file from the WPPB or include the class-file, but where and how do I initiate the class?

@VoHoTv
Copy link

VoHoTv commented Sep 1, 2021

@sintacs That depends on how the class is designed. But let's say it's a simple class with methods that should be added to a hook. Then either put it in the admin or public folder depending on what the functionality belongs to. And include it inside a method in class-plugin-name-public.php or even the load_dependencies method in class-plugin-name.php. Now all that's left to do is instantiate the class in the define_admin_hooks or define_public_hooks and hook it in.

But really, there are no good or bad ways to do it. This boilerplate is designed as a starting point for creating a plugin. And is not a framework with strict rules on what you should and shouldn't do. That is up to you :)

@sintacs
Copy link
Author

sintacs commented Apr 11, 2022

@VoHoTv Thank you for your answer. I figured it out. :D

@rolka
Copy link

rolka commented Mar 31, 2023

@DevinVinson Looks like you've got some broken image links on https://devinvinson.com/simple-login-style-plugin/

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

4 participants