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

learn more… | top users | synonyms

0
votes
0answers
5 views

Strategies for a plugin to support CDN-enabled WordPress sites

I'm writing a plugin to manage favicons. Basically it: Store image files under wp-content/upload. Inject HTML in page headers with the URL of the images. I would like to support WordPress sites ...
0
votes
1answer
28 views

Best Method to Switch Between Terms (Custom Taxonomy)

Looking to learn something, here. With the following code, I am loading an external file for each condition based on a known set of custom terms. I'm using has_terms to check for a specific value ...
0
votes
0answers
26 views

Best practice: What belongs in theme and what in plugin for large eCommerce website

I am about to create a large custom eCommerce website that does not fit within WooCommerce. (Most of the times I use WooCommerce for eCommerce.) It has also a completely custom design. However I know ...
0
votes
0answers
22 views

Trouble Dynamically Generating XML

I am trying to dynamically build a krpano viewer, the XML is output through a function where I grab stuff like hotspots from the database. I am trying to output the XML from a function, but since I am ...
5
votes
2answers
145 views

Using filters and actions for plugin API?

I want to integrate a public API to a plugin that I develop. The usual way other plugins integrate APIs is to define some functions that can be called by any theme or plugin. However, I think this ...
0
votes
2answers
38 views

Custom templates vs page-slug

I've currently been using the slug to set the page template, using the normal hierarchy For example, if I wanted to change the page template for http://www.example.com/about-us, I would edit ...
1
vote
0answers
62 views

Best Practices for a Completely Customizable Homepage - without plugins

Let's say you have a homepage where you want to be able to feature 10 posts of various types (posts, pages, and Custom Post Types). You have hundreds of these posts to choose from. What would be the ...
0
votes
0answers
22 views

Potential problems with building a plugin having sub modules?

I'm in the process of organizing a lot of different functionality that I had historically written as parts of themes so that I can break the various utilities into plugins. At this point, I have my ...
0
votes
1answer
160 views

Can a plugin add to header/footer/body content?

I am just wrapping up my first WordPress plugin and the last thing I would like to do is take a piece of data that the plugin knows about (from wp_options table) and display it in either the header or ...
0
votes
1answer
30 views

Plugin Development - Functions or Hooks?

I am brand new to WordPress plugin development and have a few questions, mostly about best practices but also some specifics. Essentially I just want to trigger an action (invoking a PHP class and ...
0
votes
2answers
121 views

Using Sessions to Filter Posts - bad thing?

I have a post type archive with filtering in a sidebar and pagination at the bottom. One of my biggest problems is that I'll always lose any $_POST filtering whenever I click pagination as the page ...
4
votes
2answers
140 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
21 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 ...
-2
votes
1answer
74 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 ...
4
votes
1answer
118 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
234 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 ...
-1
votes
1answer
32 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 ...
5
votes
2answers
871 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 ...
6
votes
1answer
360 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 ...
1
vote
1answer
424 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
2answers
479 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
110 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
175 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 ...
17
votes
8answers
2k 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
191 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 ...
0
votes
0answers
51 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 ...
0
votes
2answers
601 views

Assign Page Template Within A Custom Post Type

I have registered a Custom Post Type and created a file called archive-myCPT.php and another one for single posts called single-myCPT.php. What I want to do is to create a page where I will show just ...
2
votes
1answer
441 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 ...
0
votes
1answer
181 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 ...
0
votes
1answer
352 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 ...
6
votes
2answers
532 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 ...
0
votes
1answer
46 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 ...
1
vote
2answers
652 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
79 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 ...
3
votes
4answers
1k views

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
83 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 ...
3
votes
1answer
202 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
116 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 ...
3
votes
2answers
382 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 ...
1
vote
2answers
692 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 ...
5
votes
3answers
360 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 ...
11
votes
1answer
694 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
1answer
129 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
178 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
74 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
145 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) ...
1
vote
1answer
379 views

What's the best way to implement AJAX in WordPress?

WordPress has a framework in place for handling AJAX which is well documented here: http://codex.wordpress.org/AJAX_in_Plugins My concern with this is that every time you execute an AJAX query, (even ...
1
vote
0answers
140 views

What would be the correct way to manage a multiple locale site with Wordpress [closed]

We are a professional company with lots of big clients and have adopted Wordpress 2 years ago to build professionnal grade websites. Being locate in a multiple language country, we have to make our ...
0
votes
2answers
533 views

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 ...
17
votes
2answers
661 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 ...