Saturday, 4 May 2013
A Guide on Building Plugins Using WordPress Boilerplates
Technology has a funny way of upturning all that we know. It keeps bringing in something or the other which we thought always existed but never got implemented. For some time now, WordPress boilerplates are drawing a freaky crowd around them. There is already a global lobby of open source contributors who feel that it is an extremely wise idea. Technology is that cute little thing that comes to our rescue when things become too tiresome or cumbersome around us. You can imagine how happy a developer may become at the sight of WordPress boilerplates. After all, the developing fraternity does not need to write startup bulk codes or components for applications or sites any longer.
Boilerplates are codes which can be used in many applications and contexts without altering the original idea. In other words, they are foundational codes that help developers to come past the initial hurdles of bulk coding. This way, it becomes easy to jumpstart projects and come to a point where the ‘individualism’ of the project comes up.
It’s like setting a common base for all the flavors of an ice-cream and then put vanilla, strawberry or chocolate as needed. I am very fond of the word scaffolding. I don’t know why but it’s a very strong word literally as well as figuratively. Boilerplates are also much like scaffolding. They set a foundation upon which you can work out the standing structure of a site or an application. There are many core algorithms and functions that are only true for your programs. With boilerplates, you can readily jump to these algorithms or codes.
Files above Class and Functions
WordPress Plugin boilerplates can help developers across the world build plugins using the user-friendliness of WordPress. Constant contribution from the open-source fraternity only makes things better for global developers. With boilerplates you need to be doubly sure of the organization bit. Is it not true for life in general? In this regard, boilerplate actually becomes a microcosm for life. You have to be organized. Period. The size of a program becomes immaterial when it comes to organizing them. It is important to note that only the classes or functions do not need being organized. The essential idea is to justify or align the ‘files’ as well.
Don’t be a selfish bloke
Many of us would like to think we are generous people willing to help out others and yet when it comes to developing a site or an application, we become selfish blokes. Is there a developer who has never dumped a file into a directory, thus making life very difficult for another developer? Any developer worth his salt knows how he can assist his peers by just placing files coherently. Again, the idea is not to name the files creatively but in a very elementary way that can be easily found by your mates. Sounds right- just right! Think over.
If big guns like Ruby on Rails can sacrifice configuration for tradition, there is no reason why others cannot do it. Keeping one’s integrity intact, one can always move forward soaking the best ideas from across the world- most definitely, organizing files remains one of the key ideas.
It is a consensus that your plugin must have a minimum of one PHP. This and this alone shall be the place for piling codes, logics and functionality of a plugin. You will find developers who are prone to including all eggs in one basket. They will give you hundreds of reasons for putting everything in one file but to break the news to them- they have eggs on their faces- its being conclusively found that this does not work. You must use separate files to put different functionalities. Yes, you can definitely use the core plugin to include each such file but that’s a different story altogether. Segregating frontend code from the server side code may also be a smart idea. Well! There are many developers who would give their right arm to get the “frontend- server side” bill passed.
Now that we are getting a little cozy with the functioning of the WordPress boilerplates, let us come to another important feature called README. It permits end users to find greater meaning in the core plugins. All you need is the core plugin file and README to get on the move. However, there still may creep a few maintenance issues. This is largely because WordPress gets phenomenal number of contributions from open-source developers worldwide. Now, it is just bound to bring a few bugs on the platform, isn’t it?
All important Views
It is important to keep track of Views. This is a frontend markup which publishes elements both at the frontend and backend keeping HTML with class and ID attributes at its heart. For boilerplates, there is an admin.php and widget.php. While the first one is user or admin oriented, the second takes care of the site visitors.
Root CSS directory
Stylesheet CSS is not a flash in a pan. It has held strong for about 2 decades now. This makes the discussion on Stylesheets equally important. CSS directory holds all the Stylesheets and again admin.css and widget.css are put to use for the frontend and the backend needs. I would say that there is hardly any harm in introducing a dev directory to augment a CSS directory. This way, it becomes a lot easier to create a root CSS directory.