Questions tagged [plugin-development]

WordPress Plugins allow easy modification, customization, and enhancement to a WordPress blog. Instead of changing the core programming of WordPress, you can add functionality with WordPress Plugins.

Filter by
Sorted by
Tagged with
99 votes
7 answers
18k views

Where to put my code: plugin or functions.php?

Is there an easy to understand scheme to decide what kind of code belongs to a plugin or the theme’s functions.php? There are many cases and many debates about that topic, mostly because there are ...
fuxia's user avatar
  • 106k
36 votes
4 answers
10k views

Where do I put the code snippets I found here or somewhere else on the web?

Many posts here or somewhere else contain code, but they do not say where to put it. Example: I have found this post: How do I turn off 301 redirecting posts (not canonical)? I'm a newbie with PHP. ...
Carl's user avatar
  • 361
59 votes
1 answer
22k views

A tool to analyze rewrite rules? [closed]

Is there a good tool to analyze my rewrite rules? I always get confused with the regexes and the parameter replacements. I have created something myself and will post it here so others can use it, ...
Jan Fabry's user avatar
  • 30.4k
51 votes
1 answer
9k views

What's the preferred method of writing AJAX-enabled plugins?

I'm wondering what the preferred method is for dealing with AJAX calls. Should one use the same plugin php file to process the POST or a separate one? Which is cleaner or safer?
James's user avatar
  • 625
108 votes
2 answers
60k views

Uninstall, Activate, Deactivate a plugin: typical features & how-to

I'm making a WordPress plugin. What are typical things I should include in the uninstall feature? For example, should I delete any tables I created in the install function? Do I clean up my option ...
redconservatory's user avatar
40 votes
1 answer
25k views

Settings API with arrays example

I'm using the Wrox WordPress plugin development book as a primary reference for getting started with a new plugin and I understand all settings can be saved as 1 array but the book does't give an ...
Bjorn's user avatar
  • 702
75 votes
18 answers
7k views

WPSE Plugin Repository: The plugins that came out of WP-Answers

Link your WPSE-Plugins If you answered a question and made a plugin out of your code, than this is your place to share it. The Idea: An old comment from @MikeSchinkel during the beta phase where he ...
138 votes
36 answers
18k 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 ...
61 votes
4 answers
36k views

Difference Between Filter and Action Hooks?

I have been looking at the plugin API a bit more in depth recently and I was wondering what real differences there were between action and filter hooks. They both are events that receive data as a ...
Sruly's user avatar
  • 945
108 votes
5 answers
74k views

Best way to initiate a class in a WP plugin?

I've created a plugin, and of course being me, I wanted to go with a nice OO approach. Now what I've been doing is to create this class and then just below create an instance of this class: class ...
kalpaitch's user avatar
  • 1,193
20 votes
2 answers
22k views

Custom pages with plugin

I'm developing some plugin where I would like to enable custom pages. In my case some custom page would contain a form like contact form (not literally). When user will fill out this form and send it, ...
user1257255's user avatar
8 votes
1 answer
15k views

Export data as CSV in back end with proper HTTP headers

I wrote a plugin that displays all products in a woocommerce store in admin settings option, now I want to add a link to download the products as CSV file. The problem is, when I click the link I get ...
Yekhezkel Yovel's user avatar
67 votes
2 answers
113k views

How can I add an image upload field directly to a custom write panel?

I've added a new page under "Pages" in the wordpress admin, and added several custom fields. I'd also like to be able to add an upload image field to the page editor - is there some way to do this via ...
Will's user avatar
  • 893
16 votes
6 answers
12k views

How to include jQuery and JavaScript files correctly?

I'm doing it right now with the following code: function uw_load_scripts() { // De-register the built in jQuery wp_deregister_script('jquery'); // Register the CDN version ...
Johan Dahl's user avatar
  • 1,343
11 votes
2 answers
4k views

Symbolic Links on dev box with plugins and stylesheets

I'm using mac os x 10.6 with xampp. http://wp3.1/ is the url to where I have WordPress installed. The physical path is /Users/myUserName/Sites/wp3.1/ I do not install plugins or themes in the "...
mfields's user avatar
  • 2,692
4 votes
1 answer
11k views

How to Rewrite Wordpress URL for a Plugin

I am trying to build a Wordpress plugin here with a custom user admin area. What I would like to do is when the user adds /edit at the end of the page, it should open a page from my plugin. So for ...
Atif's user avatar
  • 1,088
75 votes
27 answers
12k views

Software for WordPress Theme and Plugin Development? [closed]

What software do you use for your WordPress related needs? Please state your OS. On windows XP I use: filezilla (FTP) notepad++ (for reading of PHP / CSS files) firebug (a firefox extension to ...
24 votes
1 answer
6k views

What is the advantage of using wp_mail?

What is the advantage of using wp_mail() over mail(). Codex says they're similar, but they seem to be very similar.
byronyasgur's user avatar
  • 3,022
15 votes
4 answers
6k views

Update widget form after drag-and-drop (WP save bug)

I've posted a bug-report about this a few months ago (on WordPress trac (Widget Instance Form Update Bug)) and I thought I'd try writing about it here too. Maybe someone has a better solution to this ...
onetrickpony's user avatar
  • 13.6k
52 votes
6 answers
9k views

framework for plugin/theme options panel? [closed]

I found that the longest part of a plugin or theme development is creating the options panel, at least in my case. So i like to know what's your take on that. Do you use a ready made framework or ...
Bainternet's user avatar
  • 67.5k
22 votes
1 answer
2k 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 ...
pixelngrain's user avatar
  • 1,390
6 votes
1 answer
12k views

Any examples of adding custom fields to the category editor?

I think I'm pretty close to cracking this nut :) I'm trying to add a set of custom fields to the Category editor. Since I'm not dealing with post meta, I believe I'll be writing my custom category ...
Scott B's user avatar
  • 5,666
1 vote
1 answer
1k views

What's the difference between hooks, filters and actions? [duplicate]

It seems like the terms hooks, filters and actions are used interchangeably. What's the difference between them? What do they do? How do I use them?
cjbj's user avatar
  • 14.1k
80 votes
9 answers
181k views

How to include PHP files in plugins the correct way

My problem is when on the main plugin file I include a PHP file something like this: include(WP_PLUGIN_URL . '/wordpress-group-buying/ipn/paypal-ipn.php'); // or include_once(WP_PLUGIN_URL . '/...
Bainternet's user avatar
  • 67.5k
30 votes
5 answers
86k views

How to add a javascript snippet to the footer that requires jQuery

I know I can add a script file to the footer of wordpress that requires jquery using this code: <?php function my_scripts_method() { // register your script location, dependencies and version ...
Saif Bechan's user avatar
27 votes
5 answers
28k views

How do I add CSS options to my plugin without using inline styles?

I recently released a plugin, WP Coda Slider, that uses shortcodes to add a jQuery slider to any post or page. I am adding an options page in the next version and I would like to include some CSS ...
Chris_O's user avatar
  • 20.6k
21 votes
3 answers
19k views

Add custom TinyMCE 4 Button, Usable since WordPress 3.9-beta1

How is it possible to add a custom button to the visual editor TinyMCE, Version 4? Currently I found this q&a with a little bit hints to the topic, but not a solution or a how to. But I can't ...
bueltge's user avatar
  • 17k
14 votes
2 answers
2k views

Strategy On Building Plugin Using Eclipse

Anyone who has experience in building wordpress plugin using eclipse PDT? My situation is: I need to build plugin that extend another plugin (look at it as premium version from another plugin) I ...
ariefbayu's user avatar
  • 1,461
10 votes
3 answers
14k views

How Do I Use jQuery UI In My Plugin

It's a sad day in the world when I Google something and it returns nothing. I am trying to use the default datepicker (or ANY datepicker at this point) and am unable to because of my lack of ...
clockwiseq's user avatar
83 votes
3 answers
28k views

Autoloading & Namespaces in WordPress Plugins & Themes: Can it Work?

Has anyone used autoloading and/or PHP namespaces within a plugin or theme? Thoughts on using them? Any harm? Pitfalls? Note: namespaces are PHP 5.3+ only. Assume, for this question, that you know ...
chrisguitarguy's user avatar
56 votes
5 answers
82k views

How can you check if you are in a particular page in the WP Admin section? For example how can I check if I am in the Users > Your Profile page?

I'm building a plugin and I want to add bits of javascript in the admin head but only for certain admin pages. I don't mean pages as in a WordPress page that you create yourself but rather existing ...
racl101's user avatar
  • 1,555
30 votes
2 answers
6k views

Enhance Media Manager for Gallery

I would like to enhance the Media Editor, after WordPress 3.5, on the gallery view. I want to add a new select field on the right side and send the selected values to the gallery shortcode. I think, ...
bueltge's user avatar
  • 17k
29 votes
4 answers
55k views

How do I create a custom role capability?

I wish to create a custom capability for accessing the interface of my plugin. Should the plugin manage adding this capability to all the administrator accounts on activation? If so: Does WordPress ...
rsman's user avatar
  • 2,290
18 votes
9 answers
12k views

check if Gutenberg is currently in use

How can I check if the editor that is currently being used is Gutenberg in a WordPress plugin? I need this because Gutenberg lacks post_submitbox_misc_actions, so I need a fallback which will only be ...
NerdOfLinux's user avatar
17 votes
4 answers
12k views

Should Plugin Folders Include a Blank index.php File?

WordPress itself, in the wp-content folder, includes an empty PHP file which looks like this. <?php // Silence is golden. ?> Should plugins include an empty file like this as well to stop ...
chrisguitarguy's user avatar
17 votes
3 answers
21k views

Pass PHP variable to javascript

Is there any possibility to pass some PHP variables in javascript so I can use them later? Only in single.php. I heard about wp_enqueue_scripts but with that it is neccesary to declare a path to a JS ...
Sebastian Corneliu Vîrlan's user avatar
15 votes
1 answer
29k views

Where is the best place to use add_filter

Should I use the function add_filter In my plugin's init action hook or just the in the main plugin script? Since sometimes I found people is using filter all over the place and if I put in the init ...
Yoga's user avatar
  • 869
10 votes
2 answers
8k views

Redesigning Custom Post Type "Add New" page

I've been browsing all over google for a solution to this. I'm writing a custom post types plugin for work to log-in visitors that we get. I initially wrote a mock-up without custom post types, then I ...
Zack's user avatar
  • 1,536
9 votes
2 answers
9k views

Get List of Registered Meta Boxes and Removing Them

Is there a function for getting a list of registered Meta Boxes and removing them? I see there is a method for adding, and removing. http://codex.wordpress.org/Function_Reference/remove_meta_box ...
Michael Ecklund's user avatar
8 votes
1 answer
1k views

How to create a flexible abstraction for WP_Query?

My question is about php but it involves wordpress as i am creating a plugin. The case is that i have 5 questions, each question have 6 choices and one choice to choose from each. Now the person would ...
localhost's user avatar
  • 484
6 votes
1 answer
3k views

How can I add columns to the post edit listing to show my custom post data?

When you click on "Posts" or "Pages", you get a paged listing of your posts or pages with the following columns: Title | Author | Categories | Tags | Date I have a plugin which gives an SEO score ...
Scott B's user avatar
  • 5,666
5 votes
3 answers
21k views

Mapping multiple URLs to same page

I just came across this page with almost similar requirements as mine Multiple endpoints to same page i have to achieve same functionality but i also want to pass some parameters to the page where ...
Umesh Awasthi's user avatar
2 votes
2 answers
2k views

How to use a Must-Use plugin to hide a regular one and to hide itself?

When solving this issue ( Change admin language based on user (in single-site) ), I did a function so that the plugin would auto-hide from all users except one (me:). The flaw is that it only auto-...
brasofilo's user avatar
  • 22k
1 vote
1 answer
1k views

Trying to avoid including wp-load.php

I am working a plugin where I am trying to connect an HR system with WordPress. There is an XML API on the HR system so I have written the plugin to take the data and put it into a WordPress database ...
Omar Mir's user avatar
  • 159
125 votes
7 answers
106k views

add_menu_page() with different name for first submenu item

The add_menu_page documentation says to pass the menu title as the second parameter: add_menu_page('Page Title', 'Menu Title', ...); When adding more pages later via add_submenu_page, the main page ...
MegaHit's user avatar
  • 1,533
45 votes
1 answer
11k views

Should I use custom post types or a custom database tables for plugin development?

I'm fairly new to writing wordpress plugins, but I've jumped in the deep end already and I want to make sure I'm doing it "right" on my upcoming big project. I'm going to be heavily extending ...
Jeff's user avatar
  • 2,515
36 votes
5 answers
29k views

What's the difference between term_id and term_taxonomy_id

The title says it all. At the moment in my custom taxonomies I'm getting the terms using the term id and taxonomy name. Thought this question would've been asked before but can't find it anywhere! So ...
Daithí's user avatar
  • 665
32 votes
5 answers
28k views

Post meta vs separate database tables

When developing plugins that requires data storage, what's the pros and cons of using one method or another ? The explanation given in the codex is not detailed: Before jumping in with a whole new ...
Nassif Bourguig's user avatar
32 votes
3 answers
21k views

Why does WordPress use outdated jQuery v1.12.4?

While checking the source code, I saw that WordPress uses jQuery v1.12.4. Why does WordPress use this outdated version of jQuery?
Sandun's user avatar
  • 454
20 votes
5 answers
30k views

"Error: Options Page Not Found" on Settings Page Submission for an OOP Plugin

I am developing a plugin using Tom McFarlin's Boilerplate repository as a template, which utilizes OOP practices. I've been trying to figure out exactly why I'm unable to correctly submit my settings. ...
gate_engineer's user avatar

1
2 3 4 5
12