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

learn more… | top users | synonyms

0
votes
1answer
11 views

Should I paste CDN links in a JS file or use a Bootstrap CDN plugin?

I'm new to WP development and I don't have the experience to know if I should place CDN links in a JS file and enqueue it or use a nifty plugin such as this one. What is best practice? What should I ...
0
votes
1answer
42 views

Custom Post Types and Removing Slugs - should we do it?

I've run into issues trying to remove my custom post types slugs and I've read other questions on here from people with the same problem. We don't want that slug in our URL! But the solutions to this ...
0
votes
0answers
15 views

Registering an optional custom post type from a plugin

I see the codex notes to call flush_rewrite_rules() on plugin activation and deactivation when registering a custom post type from a plugin but I'm looking for the best practice if a plugin gives ...
0
votes
1answer
50 views

Why user_pass column in wp_users table is varchar(64)

while working on a project, I found that "user_pass" column in "wp_users" table is varchar(64). WordPress always stores user password in md5 which is a 32 char ASCII string. So why not store it in ...
0
votes
2answers
31 views

Should non-WordPress data get its own DB?

I couldn't find anything on Google or on here about best practice for data that is not really Wordpress related. Say we have a database of clients that we'll be accessing through PHP/SQL. Should I ...
0
votes
0answers
17 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
37 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
38 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
30 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
180 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
44 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
70 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
27 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
271 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
37 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
142 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
153 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
26 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
90 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
122 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
269 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
34 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
946 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
405 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
540 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
542 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
114 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
176 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 ...
18
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
209 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
54 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
677 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
490 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
198 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
395 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
575 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
47 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
728 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
81 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 ...
4
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
87 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
220 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
135 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
412 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
754 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
370 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 ...
12
votes
1answer
753 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
136 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
180 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 ...