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

Include Shortcodes / Image Size Inclusion / Single CPT Template Howto #418

Closed
jasperf opened this issue Feb 20, 2017 · 3 comments
Closed

Comments

@jasperf
Copy link

jasperf commented Feb 20, 2017

Been reading some of the issues as I am building a projects portfolio plugin based on the WordPress Plugin Boilerplate. Devin mentioned a way to include shortcodes.. Another user also talked about it here.
I did more or less follow these instructions and adjusted my repo Ianua Projects. I moved the shortcode I made to the public class, adjusted the general class and loader too. Issue I had is that I could only use add_action in the main class and not add_shortcode as I got a count_error. Too few parameters I guess so I reverted to the way I added it before using an extra class to add the shortcode in the public class.
If I would like to add another add_image_size function using an add_action, would I add it to the main class loading the function from the public class? That the best way?
Two, should I move the custom post type to public class from the admin folder too? Seems like the best way and single cpts will definitely be public...
Three, was trying to figure out the proper way on adding a single cpt template or adjusting the display of the single post view it is loading without now. Found Slushman's now hiring plugin and mention of single template view code here. So digging some more there, but any tips / tuts are very welcome!

@DevinVinson
Copy link
Owner

It has been a while since I added a shortcode but always making sure you are starting with a basic shortcode and working back up to your more complicated one is what I would do to debug further.

You don't need to worry about what is "best" for public vs admin. It is purely individual choice and makes no real difference. If you feel CPT is publci then throw it in public.

@jasperf
Copy link
Author

jasperf commented Feb 21, 2017

Thanks for the feedback Devin. I managed to make the shortcode work as part of the public class. Do think it belongs there. Will need to tweak it a lot more. Also kind of large so perhaps it needs to go into its own file. But made it work.
Next step will be a basic options page where a basic intro text can be added and some text explaining how things work will be added. That and the template for the single CPT. Everything a step at the time I guess.
Thanks for the feedback @DevinVinson . Really appreciate you taking the time answering my question and all the work on the Boilerplate really.

@seldimi
Copy link

seldimi commented May 12, 2017

Hey. I also seek a way to organize things on boilerplate. When you build plugins, not everything can fit int 5-10 files.
Searching around I've found this plugin which I think covers the most with boilerplate. You can check how CTP were made.
https://bitbucket.org/angelleye/paypal-ipn-for-wordpress/overview

I was thinking of making a CTP class system (some people say its better) and breaking down the big files to smaller ones.

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

3 participants