DevinVinson / WordPress-Plugin-Boilerplate

[WordPress] A foundation for WordPress Plugin Development that aims to provide a clear and consistent guide for building your plugins.
http://wppb.io
7.67k stars 2.25k forks source link

No documentation/tutorials #269

Open kitkat14 opened 9 years ago

kitkat14 commented 9 years ago

First of all i want to thank you for making such a great plugin in order that people will start making plugins as they should have (including me).

But your mission will not really succeed if people dont know how to use it... I have waited some months but there are still nothing happening on that front...

So any plans to make 1 tutorial of how to use it to create backend and a front end stuff from the boilerplate ?

tommcfarlin commented 9 years ago

But your mission will not really succeed if people dont know how to use it... I have waited some months but there are still nothing happening on that front...

I know - documentation is something that I've wanted to complete for sometime, but given that this is a free project and is something that I can work on only as time allows, I simply haven't had time to work on it just yet.

I do have a course coming out on how to use it to build a plugin soon and I'll blog about it as soon as it's released.

I appreciate the patience.

kitkat14 commented 9 years ago

Yeah I know :) it's free and in your own time so it's double appreciated. Where do you have courses ? Udemy ?

tommcfarlin commented 9 years ago

Where do you have courses?

No - this one will be featured on WP Sessions sometime in the near future :).

kitkat14 commented 9 years ago

Oke :)

Maybe some qq you can answer.

The public folder is all that happens on the front end right ? Say I want to add a class Building and add bootstrap CSS and JS. You make a class in that folder and add the stuff in the corresponding CSS and JS folder right.

So how do you enque more than one js in the public php class ? I am getting a bit confused with so much separation :)

Op dinsdag 24 februari 2015 heeft Tom McFarlin notifications@github.com het volgende geschreven:

Where do you have courses?

No - this one will be featured on WP Sessions sometime in the near future :).

— Reply to this email directly or view it on GitHub https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate/issues/269#issuecomment-75807407 .

tommcfarlin commented 9 years ago

The public folder is all that happens on the front end right ?

That's correct.

Say I want to add a class Building and add bootstrap CSS and JS. You make a class in that folder and add the stuff in the corresponding CSS and JS folder right.

Assuming that you want to use Bootstrap in the front-end, then you'd place those in the public/js and public/css folders; however, since they are libraries, I'd also consider creating a lib directory in each of the subdirectories to indicate that these are third-party files.

Secondly, I'd also do a check in the code to make sure Bootstrap hasn't already been registered and enqueued since it's such a popular framework.

So how do you enque more than one js in the public php class ?

You'd make multiple calls to wp_enqueue_script - one for each file that you want to enqueue. Just make sure that you order them properly and that you set the proper dependencies so they are loaded correctly on the front-end.

kitkat14 commented 9 years ago

But in the public class you do something like this.

Public function enqueue_styles(){ wp_enqueue_style($this-classname, and so on) }

If you do this a second time (so you want to add another script or CSS) it will not work.

Op woensdag 25 februari 2015 heeft Tom McFarlin notifications@github.com het volgende geschreven:

The public folder is all that happens on the front end right ?

That's correct.

Say I want to add a class Building and add bootstrap CSS and JS. You make a class in that folder and add the stuff in the corresponding CSS and JS folder right.

Assuming that you want to use Bootstrap in the front-end, then you'd place those in the public/js and public/css folders; however, since they are libraries, I'd also consider creating a lib directory in each of the subdirectories to indicate that these are third-party files.

Secondly, I'd also do a check in the code to make sure Bootstrap hasn't already been registered and enqueued since it's such a popular framework.

So how do you enque more than one js in the public php class ?

You'd make multiple calls to wp_enqueue_script - one for each file that you want to enqueue. Just make sure that you order them properly and that you set the proper dependencies so they are loaded correctly on the front-end.

— Reply to this email directly or view it on GitHub https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate/issues/269#issuecomment-75959693 .

tommcfarlin commented 9 years ago

If you do this a second time (so you want to add another script or CSS) it will not work.

It won't work if you don't give each script a proper ID. If you make sure they are unique. See this page for more information.

user52839307 commented 9 years ago

Thank you for clearing that up. I could not understand why it would not load more than one script, it was staring me in the face.

Your examples for loading the javascript and css are using the variable $this->plugin_name for the handle. I just needed to add a unique extension string like $this->plugin_name . '-javascript' for each additional script and it worked fine.

NebriBlackwing commented 8 years ago

I have found this tutorial to be extremely useful when getting started with this plugin:

https://www.sitepoint.com/wordpress-plugin-boilerplate/