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

learn more… | top users | synonyms

3
votes
2answers
54 views

How to make a text with hyperlink translatable in WordPress?

I've seen different ways of doing making a text with a hyperlink translatable. However, I have been unable to find a single best practice. So, some of the solutions I found: // METHOD 1 sprintf( __( ...
0
votes
0answers
8 views

Best practices for using plugin source in multiple projects with tortoise

Today I uploaded my first two plugins to WordPress. I use these plugins in most of the websites I develop. I am using NetBeans on my desktop. I am trying to figure out how to best use Tortoise SVN to ...
5
votes
3answers
307 views

Best Practices for Seperating jQuery from HTML/PHP

I am creating several jQuery scripts to help validate forms before they are submitted. I have read that it is best to always separate jQuery scripts into a separate file so that you can load the ...
-2
votes
1answer
51 views

When is it OK to create a custom table for a plugin? [duplicate]

A while ago I wrote a question asking about storing easily queryable data associated with a given attachment. The recommendation that I received at the time was that I should avoid using the WP ...
22
votes
7answers
8k 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 ...
1
vote
5answers
10k views

WordPress product catalog site [closed]

I need to create an e-commerce site with WordPress, but not 100% e-commerce. It is just a catalog site without shopping cart. Users can see various products on the site, for example, car showcase ...
5
votes
2answers
577 views

Creating Ajax backend for Specialised Page Template? Should admin-ajax.php be used?

We're scoping an upcoming project that will require the development of a large php web application within an existing wordpress site - this is for our use only and we've no intention of trying to ...
4
votes
1answer
101 views

Dealing with Many Meta Values, 30+

I have a "Listing" post type with 30+ meta keys which I feel like can cause a strain on the database when there's 100+ posts. Usually what I do is save each meta value 1 by 1 like so: ...
0
votes
1answer
118 views

Set cookie for visitor

I'm writing a new plugin that will allow visitor to vote. After a visitor rated a post, I'd like to block double voting. I think the better way to do it is using cookie, but of course I can't insert ...
4
votes
4answers
1k views

What is the best way to load the WP environment in a subdomain of my multisite Wordpress install?

I have a subfolder install of WP multisite, let's say at "domain.com". I now need to load the WP environment in subdomains of domain.com, say "sub1.domain.com", "sub2.domain.com", ... ...
-1
votes
1answer
28 views

Best practice to create required pages

Some times, when we work on custom wordpress themes, we need required pages. For example - custom login page. Some times, when user change slug, page template or something else - it a very difficult ...
6
votes
1answer
232 views

Why doesn't WP_Image_Editor save images using the Filesystem API?

I was in the process checking some of my existing plugins for any unsafe filesystem accesses, when I ran across WP_Image_Editor's save function, which calls _save, which finally calls make_image ...
0
votes
1answer
176 views

Default value for add_settings_field

I'm creating a simple settings page by following these instructions. Since this is a custom plugin, I'd like one of my settings to start with a predefined value (that can later be changed). What is ...
0
votes
1answer
197 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 ...
-2
votes
1answer
80 views

Why haven't I see plugins using get_file_data to handle retrieving plugin version?

In terms of best practices, I'm curious as to why I haven't seen anyone using get_file_data or get_plugin_data to handle getting a plugin version (for versioning CSS/JS files). Many quality plugins do ...
7
votes
2answers
156 views

What is right way to go about adding functionality to a published WordPress plugin?

So I looked all over to try and find some kind of rules, or at least some common-courtesy guidelines, concerning this issue and couldn't find anything. Essentially I'm wondering what I should do when ...
15
votes
7answers
713 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 ...
0
votes
1answer
144 views

Is it advisable to use `add_rewrite_rule()` to serve a custom page?

I have a page called "dynamic" that's not stored in the post table at all (not a post, page or custom post type of any sort); the reason being is all the data is completely dynamic based on $_GET ...
60
votes
8answers
17k 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 ...
0
votes
0answers
46 views

“Static” pages within a theme

What I want to achieve is to add vCards to my contact pages, created on the fly and downloadable. I guess I could make a very bare template with the functionality and the correct mime-settings to the ...
2
votes
1answer
220 views

CMS: Making complex pages editable by the end user

I have been tasked with re-creating a small-ish corporate Web site (maybe a dozen static pages and a blog section) using WordPress. I have no troubles with the actual Web design, nor with the PHP ...
88
votes
37answers
12k 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 ...
5
votes
2answers
740 views

Complex widget form UI - examples and best practices

I'm contemplating a widget with quite a number of options, which will make for a lengthy widget form. To improve the user experience with this form, I'd like to divide it into sections. I don't feel ...
0
votes
1answer
110 views

restore_current_blog() vs. multiple switch_to_blog() followed by removing $GLOBALS['_wp_switched_stack']

Related to this answer, which states After every instance of switch_to_blog() you need to call restore_current_blog() otherwise WP will think it is in a "switched" mode and can potentially return ...
5
votes
3answers
564 views

Using Images in Wordpress - Best Practices

I'm not a novice to Wordpress Theme Design & Development. I've actually been doing it for a few years now and in recent years, it has become more than a hobby and is slowing shaping into a career ...
1
vote
2answers
2k views

WordPress for a business catalog site

I am completely noob with WordPress so I apologize in advance if my questions sounds completely stupid. Background I have a small business catalog site that I wrote long ago in plain HTML. Now I ...
0
votes
1answer
178 views

How long is “as long as possible” in wp_cache_set()?

The documentation for wp_cache_set() says that if you pass in 0 for $expire (which is also the default), then it is cached for "as long as possible". How long is this? What determines it? Are we ...
1
vote
1answer
99 views

Customizing page content layout

For a while now I have been building WordPress based sites for clients. These sites tend to be brochure sites so feature a collection of pages all with slightly different layouts within an ...
0
votes
1answer
42 views

Enqueue scripts based on options

What is the best method to enqueue scripts based on options I have? Let's say I have 50 options and for each I need to enqueue a script(some of them might repeat.). Can I have any ...
6
votes
2answers
330 views

Wordpress and event-driven programming - what is it about?

I want to state very clearly that this does not intend to revive the discussion about functional/procedural programming versus object-oriented programming. There is plenty said about that, on WPSE and ...
10
votes
1answer
527 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 ...
0
votes
2answers
318 views

How to optimize multiple WP_Query() calls on one page?

The current site I'm building has a homepage that is going to have around 10 instances of WP_Query(). Some of them are going to pull a series of posts, while others are targeted at one single post ...
2
votes
1answer
68 views

Naming script handles right way

I was wondering is there any convention or what is the right way for naming handles in wp_register_script() and wp_register_style() functions? For example if I am developing a plugin that uses ...
1
vote
3answers
317 views

Wordpress best practice - should I delete the default themes?

when managing a Wordpress site it gives me great pleasure to see nothing needs updating. Should I delete the default themes or is it best to leave them there? By default themes I mean: Twenty Eleven ...
0
votes
1answer
65 views

Best Way to Add UnEditable HTML to Posts

I find myself more and more needing to use tables or divs inside my wordpress posts content. The problem I find with this is that one wrong backspace or newline, copy / paste has the possibility to ...
17
votes
2answers
528 views

Is it ever okay to include inline CSS in plugins?

Normally in a plugin I would add styles using wp_enqueue_style. However, I am currently creating a plugin that only needs a few lines of CSS and I am wondering if it might be better to serve the ...
28
votes
3answers
2k 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( ...
3
votes
1answer
120 views

How can I import a class privately into a plugin?

I've written a Wordpress plugin that makes use of a simple controller/templating library I have authored, to separate out business logic from presentation. I have a (slightly theoretical) query about ...
2
votes
1answer
92 views

Is there an action/filter called when WP_Query->query is finished and assigns posts

I took a look at the WP_Query->get_posts() function and couldn't see any action/filter that is called AFTER a query finishes. I want to be able to manipulate the results once they are sent, rather ...
9
votes
2answers
320 views

Plugin SVN & update API - how are plugins identified?

One thing that's never been clear to me (especially since I haven't submitted a plugin to the repository) is how a plugin's unique "ID" (slug) is generated (i.e. this list). Is it a choice by the ...
1
vote
3answers
466 views

will post_id ever change? Can I safely use post_id for custom queries?

What are the best practices for using post_id? Can I use this safely in my templates to call specific posts, or will these post_id's ever change? The reason I ask is that randomly today the ...
3
votes
2answers
305 views

Best practice - Meta Query vs. post_clauses for “left join” ordering

Moreso a psuedo-code question than actual code. I have some custom post meta attached to attachments, and created a list table column for this meta. The meta is either 1, or null (not set), but I am ...
3
votes
2answers
102 views

Which to use to execute code during the saving of a plugin settings page?

I'm writing a plugin with a settings/option page and I want some php code to be executed whenever someone saves the settings on that page and that page alone. Which actions do I need to hook into to ...
25
votes
7answers
5k 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?
1
vote
2answers
482 views

What is WordPress file encoding?

I noticed that WordPress files use UNIX end-of-line and UTF-8 without BOM. Is this a standard that should be used? Is there anything else to pay attention to? I noticed that Filezilla fails to ...
1
vote
2answers
107 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
104 views

What are the best practices for maintaining and deploying several parent themes?

I've been trying to commission a freelancer to make me a custom website and hit a roadblock when I said I wanted a parent theme. The freelancer strongly preferred to make a child theme based on his ...
1
vote
3answers
166 views

How to break down importing of feeds

I am attempting to update a large array of feeds into WordPress, using fetch_feeds. As can be expected, when going over 50 feeds the server is starting to time out. I would still like to update the ...
1
vote
2answers
72 views

apply filters only to specific post listing without check the url parameters

I have made a custom post type named as: slider, in my plugin class, I am adding a filter which calls the method remove_row_action that unsets view links from actions ...
0
votes
2answers
121 views

What are the main parts of a Wordpress Template?

This may sound like a stupid question, but... What are the main parts of a Wordpress template, and which parts are mandatory and which parts are optional? So far I am aware of: Posts (mandatory) ...