For best pratices please see the WordPress coding standards, to be found in the Core Contributor Handbook.

learn more… | top users | synonyms

85
votes
37answers
10k views

Objective Best Practices for Plugin Development? [closed]

Starting a community wiki to collect up objective best practices for plugin development. This question was inspired by @EAMann's comments on wp-hackers. The idea is to collaborate on what objective ...
21
votes
3answers
1k views

How to remove a filter that is an anonymous object?

In my functions.php file I would like to remove the below filter, but I'm not sure how to do it since it's in a class. What should remove_filter() look like? add_filter('comments_array',array( ...
5
votes
3answers
4k views

don't publish custom post type post if a meta data field isn't valid

I have a custom post type (CPT) called event. I have a meta box for the type with several fields. I would like to validate some fields before publishing an event. For example, if an event's date is ...
47
votes
8answers
13k views

Is moving wp-config outside the web root really beneficial?

One of the most common security best practices these days seems to be moving wp-config.php one directory higher than the vhost's document root. I've never really found a good explanation for that, but ...
20
votes
6answers
6k views

Conditionally Loading JavaScript/CSS for Shortcodes

I released a plugin that creates a shortcode and requires a JavaScript file and a CSS file to load on any page that contains that shortcode. I could just make the script/style load on all pages, but ...
38
votes
6answers
2k views

Best-of-Breed Features of a High-End WordPress Web Host? [closed]

I'm posting this as a community wiki because I'd like to get a collaboratively edited list of features for a high-end WordPress webhost. For example, if you are running a high-traffic ...
11
votes
2answers
3k views

Best practices for localizing WordPress content?

A client asked for a blog that will have localized content (i.e. en.blogname.com for English content, fr.blogname.com for French content, etc). Being new to building such a blog, we recently ...
34
votes
3answers
2k views

Opinions and recommendations on the best barebones base theme [closed]

Preamble I'm finding myself building more and more WP sites "from scratch" as it were (ie: ignoring any theme designs out there and just creating a design wireframe purely on the needs of the client. ...
10
votes
1answer
449 views

How to create an API for my plugin?

I have been developing plugins for WordPress, most plugins I have developed use two or three classes, hence not as huge as Buddypress or WooCommerce. I am planning to develop two open source plugins ...
14
votes
4answers
2k views

Plugins in symlinked directories?

When I develop plugins I test them on multiple versions of WordPress by symlinking my plugin directory in the different wp-content directories. This is great since I only have to edit the files once, ...
7
votes
2answers
2k views

Return $post_id when DOING_AUTOSAVE?

I see the following pattern over and over, on this site and on other places: add_action( 'save_post', 'wpse14169_save_post' ); function wpse14169_save_post( $post_id ) { if ( defined( ...
14
votes
2answers
443 views

In Which Contexts are Plugins Responsible for Data Validation/Sanitization?

I want to make sure all of the data in my plugins/themes is handled securely before entering the database and before being output to the browser. My problem is that there are situations where the API ...
7
votes
2answers
5k views

How do i best handle custom plugin page actions?

I'm constantly running into the same annoyance, so i thought i'd see if there's any ideas or experience out there... I've created a plugin that uses it's own admin page. It has to. Now that i sorted ...
7
votes
2answers
3k views

Use wp init hook to call other hooks?

I want to know if it is a good practice according to WordPress theme or plugin development. add_action('init','all_my_hooks'); function all_my_hooks(){ // some initialization stuff here and then ...
7
votes
1answer
140 views

Shared functionality in plugins and themes

I recently started to develop plugins and themes and I found that I need to use several functions of on both. Sometime I think about to check if function / class exist before declared as said on this ...
4
votes
2answers
693 views

What are the current recommended best-practices for comments.php?

I'm getting ready to submit a theme to the .Org repo and wanted to make sure that everything is in ordnung. One of the biggest holes left in my design is the comments template. I've taken a look at ...
44
votes
7answers
6k views

Best collection of code for your .htaccess file [closed]

We have the Best Collection of Code for your functions.php file thread, so I thought that it might be useful to create a thread for our .htaccess files. AND PLEASE REMEMBER TO ADD ANY OF YOUR OWN ...
25
votes
7answers
4k views

When Should we NOT Recommend a Client use WordPress? [closed]

As responsible professionals there has to be a line where we say, WordPress is not supposed to be used for that. When is WordPress not the answer?
7
votes
3answers
245 views

Getting a peer review for my new plugin?

What is the best way to get an experienced WordPress developer take a look at my plugin and give constructive criticisms? I have written code to solve some of my questions on this site, and I think ...
12
votes
2answers
1k views

Best Practices for Regression Testing WordPress Websites?

Hi all, I'd like to hear what others who are delivering complex non-blog solutions to clients with WordPress as a platform what they are using for automated Regression Testing? For those not ...
14
votes
7answers
298 views

What is your best practice to execute one-time scripts?

The Problem We all have been in a situation like this, and a lot of questions on this site need a solution like this. You either have to update a database, insert a lot of data automatically, convert ...
13
votes
4answers
681 views

Why have <?php and ?> on every line

I've seen this convention pretty much everywhere, and, at times, it comes close to driving me nuts: <?php //The loop ?> <?php while ( have_posts() ) : the_post(); ?> <?php ...
5
votes
1answer
226 views

Optimize shortcode callbacks

I created a plugin to add some shortcodes in my WordPress site. But I'm a PHP newbie, so I believe it may have some errors or ways to optimize it. It's working fine, and apparently there are no ...
6
votes
1answer
3k views

get_template_directory() vs bloginfo( 'template_directory' ) vs TEMPLATEPATH

I was reading this article: Common WordPress Development Mistakes and How to Fix Them, and in it, they author says: Getting the theme location: If you are using TEMPLATEPATH or bloginfo( ...
5
votes
2answers
2k views

Making $ globally accessible with jQuery.noConflict()

The Codex promotes this method of using $ inside a plugin/theme JavaScript file: jQuery(document).ready(function($) { // $() will work as an alias for jQuery() inside of this function }); But ...
10
votes
1answer
8k views

numberposts? showposts? posts_per_page?

So the documentation on the Codex is pretty clear that showposts is deprecated. But that same documentation mentions nothing of numberposts. Instead, posts_per_page is listed. But if we turn to the ...
5
votes
2answers
794 views

Pitfalls when Distributing Plugins that Access SOAP Web Services?

I'm wondering what pitfalls (if any?) developers here have run into when distributing WordPress plugins via the WordPress plugin repository that embed a SOAP client for accessing SOAP web services for ...
4
votes
4answers
1k views

Where to put third party PHP library?

I'm developing a couple of open-source plugins and a theme (all part of a "suite") that all use the same third party PHP library. I'm wondering what is the best way to include it in Wordpress. Here ...
3
votes
1answer
97 views

Hyphens vs. periods in the script slug in wp_register_script?

I have seen script and style handles written in two different ways in wp_register_script and wp_enqueue_script (the same applies to wp_register_style and wp_enqueue_style): wp_register_script( ...
2
votes
1answer
437 views

When to check if a function exists

I've just started developing a WP plugin, and i've been reading some code from other plugins as a way to get started. I've seen a couple of plugins that wrap all or some of their functions in the ...
1
vote
2answers
95 views

Failed to invoke other hook from the init hook

Related to this question (Use wp init hook to call other hooks?) but not the same. Sometimes, I found that the hook will failed to run when I place inside the init hook, e.g. Not Work: ...
0
votes
1answer
83 views

(Beginner) Need help installing Wordpress on my VPS (Virtual Private Server)

Introduction: (I will remove this later of course) Hi. I think it would be smart for me to ask the professionals how I can best install WordPress on my VPS so that I don't run into problems with my ...
0
votes
2answers
381 views

TwentyTen: Overloading template.php files vs. get_template_part

I'm studying TwentyTen, under the assumption that it contains the best practices for writing themes and modifying them using child themes. I'm noticing what looks like a really redundant practice, ...