Articles of coding standards

Class or function wrapper for plugin code

When developing plugins, to avoid using a prefix for all functions and variables, it is common to use a wrapper for the plugin code. I have seen in many places the practice of using a class and I want to compare that to simply using a function as a wrapper. A. Class wrapper class Nice_Plugin […]

WordPress Theme Validator?

I’m looking for a WordPress theme Validator. Not necessarily something that validates the HTML but more along the lines of adhering to the WordPress Coding Standards for Theme Development.

Do define() statements need phpDocumentor-style docblocks?

There’s no word on this in the WordPress Documentation Standards, but do define() statements need phpDocumentor-style docblocks? /** * Should this docblock be here? * * @since 1.0.0 */ define( ‘MY_CONST’, ‘Hello’ ); // Or would a comment be more appropriate? define( ‘MY_CONST’, ‘Hello’ ); For reference, the list of elements to be dockblock’d that […]

Why the WP Core team does not allow filter_* functions?

This question is somehow related to this other question. Provided that is seems we have a solution for the magic quotes issues, why the WP Core team does not allow them? This is unclear to me and I couldn’t find any official statement explaining this decision: just mentions sparse in some trac tickets and blog […]

Can I use namespaces in my plugin?

I am building a plugin that I hope to eventually put on Envato CodeCanyon. Currently I am creating functions of the form mypluginname_action. This is quickly becoming silly as I have to do that a lot. I’m thinking of using PHP namespaces, but I’m worried that there might be a reason why I shouldn’t. Are […]

spaces inside parenthesis

The WordPress coding standards states to put parenthesis both inside and outside opening and closing parenthesis. What is the rationale behind spaces on the inside of parenthesis? I’ve hardly ever seen that in any other code except PHP.

REQUIRED: Could not find wp_link_pages. See: wp_link_pages by Theme Checker

I have run my theme through WordPress theme checker to see if it can be submitted to WordPress.org. I encountered this error: REQUIRED: Could not find wp_link_pages. See: wp_link_pages But this is not true. I am using a custom function wp_my_own_link_pages() which is a replacement for wp_link_pages(). It generates pagination with a compatible HTML structure […]

What make possible unit test plugins?

This is more a theory related question. I’m not looking at the practical ways to do this, as I can find plenty of example (official and not), which however does not explain how it is possible to properly create and run tests for elements of code that relies so much on the system (WordPress) and […]

What's the best practice way of handling custom fields in different post formats?

I am developing a theme that is compatible multiple post formats (video, audio, gallery, status, quote, etc.) From the perspective of a theme developer, what is the best practice way of handling custom fields in these different post formats? So say for example, you have a theme that supports video post formats. The only difference […]

Is it better to create a function or a variable for current_theme_supports?

Well I just asking myself this, there are two ways I could implement this. What would be a better fit to coding standards? Or is this just a a matter of personal like? And what about php and memory, assuming this would be way more complicated and executed very often. Would it cost more memory […]