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
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 ...
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
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
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
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
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
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
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 ...
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 ...
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
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
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
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
54 votes
10 answers
30k views

How to structure a plugin

This isn't a question about how to build a WordPress plugin. Rather, what, if any, guides could be applied to how to put together the file architecture of any plugin. Some other programming languages ...
52 votes
7 answers
67k views

Creating a table in the admin-style?

What is the recommended way of creating a page with a table, in the style of the tables showing posts or users in the admin area? I am expanding the Cache Images plugin, and it contains a table with ...
Jan Fabry's user avatar
  • 30.4k
52 votes
16 answers
13k views

How do you debug plugins?

I am pretty new to plugin authoring and was having a hard time debuging. I used lots of echo and it is sloppy and ugly. I am sure there is a better way to do this, maybe an IDE with a debugger that ...
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
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
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
44 votes
3 answers
34k views

What are the differences between WPINC and ABSPATH?

It's common for plugin developers to protect their plugins from direct access. I saw two ways to do that: if ( ! defined( 'WPINC' ) ) die; and if ( ! defined( 'ABSPATH' ) ) exit; What are the ...
Daniel's user avatar
  • 1,186
43 votes
3 answers
8k views

Add multiple plugin directories

The task You can register add additional Themes directories using register_theme_directory() for your WP installation. Sadly core doesn't deliver with the same functionality for plugins. We already ...
kaiser's user avatar
  • 50.5k
41 votes
2 answers
119k views

How to get the path to the current theme?

This code is used to get the directory of the current plugin: plugin_dir_url( __FILE__ ). What should I use to get the directory of the current theme?
porton's user avatar
  • 791
40 votes
5 answers
153k views

ajaxurl not defined on front end

I am trying to create a ajaxform on the front side. I am using the code jQuery.ajax( { type: "post", dataType: "json", url: ajaxurl, data: ...
dread_cat_pirate'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
39 votes
2 answers
65k views

How to add a shortcode button to the TinyMCE editor?

How to make any plugin icon in wordpress post? The code I want to insert in plugin code and will appear in post bar [wp-admin/post.php]. Like this image: Output: If I click the icon it automatically ...
Juan Lie's user avatar
  • 653
39 votes
4 answers
40k views

How to make a plugin require another plugin?

I'm building a plugin that adds extra functionality to a main plugin. Ideally in the plugins administration screen, the "activate" link should be disabled and an inline note should be added that tells ...
kosinix's user avatar
  • 1,454
38 votes
3 answers
55k views

Should I use wpdb prepare?

I'm new to SQL and am wondering if I need to use wpdb->prepare for the following query to a table I've created global $wpdb; $tablename = $wpdb->prefix . "my_custom_table"; $sql = "SELECT * ...
Richard Sweeney's user avatar
37 votes
10 answers
13k views

What process do you use for WordPress development? [closed]

I'm interested in how other people develop themes and plugins for WordPress. To me, the in-browser editor in the admin panel just doesn't cut it. Currently, I'm just using an IDE with a PHP plugin (...
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
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
34 votes
7 answers
3k views

What Plugins Demonstrate Great WP Plugin Development? [closed]

I'm going to be tackling my first plugin soon and I'm looking for plugins which you feel are of very high quality, under the hood. Stuff I can use as an example while I design the framework for my ...
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
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
5 answers
10k views

Is there any plugin development framework

Since I am new to WordPress plugin development I have been examining the internal structure of many plugins. I have found that most of them don't fit any pattern and so understanding how they work can ...
Rohith Raveendran's user avatar
32 votes
1 answer
9k views

Is it possible to reuse wp.media.editor Modal for dialogs other than media

To expand: I'd like to utilize the same Modal code/appearance ( as used in wp.media.Modal, wp.media.FocusManager ) to open a modal of my own custom dialog, not the Media Editor. In the past, I've ...
Jer's user avatar
  • 481
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
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
5 answers
30k views

How to add an admin notice upon post save/update

I have a post type the uses post_save to take the address from the post-meta and retrieve the lat/lng coordinates from the Google API. I need a way of notifying the user if there was an issue with ...
Jason's user avatar
  • 403
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
28 votes
10 answers
32k views

is_plugin_active function doesn't exist

I'm using WordPress 3.0.5 and have tested with 3.1rc4. In the main PHP file of my plugin, when I try to call is_plugin_active I get Call to undefined function is_plugin_active(). I can call add_action ...
Carl's user avatar
  • 383
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
26 votes
3 answers
48k views

How to include a file using get_template_part() in a plugin?

A very simple question may be, but I'm struggling. In theme development, I worked with get_template_part() many times, and I understand its basics. But when I's developing a plugin, I wondered using ...
Mayeenul Islam's user avatar
26 votes
3 answers
33k 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 ...
wyrfel's user avatar
  • 3,075
26 votes
1 answer
966 views

Adding Custom Text Patterns in the WP 4.5 Visual Editor

4.5 is out and with it new Text Patterns. I would like to know how to go about adding my own custom patterns. Taking a look at wp-includes/js/tinymce/plugins/wptextpattern/plugin.js it seems pretty ...
jgraup's user avatar
  • 9,699
25 votes
3 answers
2k views

Automatically determine minimum WordPress version required for a plugin?

When developing a plugin, is there a way to automatically determine the minimum version of WordPress that's required to run it? I want to make sure that the Requires header is accurate, but manually ...
Ian Dunn's user avatar
  • 4,817
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
23 votes
2 answers
37k views

How to change a user's password programatically

I am trying to create a totally different profile page (not the one provided by Wordpress), since the layout and feel of the default profile page is too "Wordpress" for the users. Now I am successful ...
Ardee Aram's user avatar
23 votes
2 answers
16k views

How to make a WordPress plugin translation ready?

What is the best way create a plugin that is translation ready? It doesn't have to be translated from the beginning but it has to be easily translatable so fellow developers from different cultures ...
Nabil Kadimi's user avatar
  • 2,686
23 votes
1 answer
31k views

How to override existing plugin action with new action

I'm using a plugin. It has an action like this. add_action('publish_post', 'old_action'); function old_action($pid) { "code goes here" } } I'm writing a module for this plugin. So i need to ...
PrivateUser's user avatar
  • 3,441
23 votes
3 answers
11k views

How to store username and password to API in wordpress option DB?

I'm currently developing a plugin and the chances are that I will more than likely release it on the public plugin repository so others can use it. The plugin will be using an API and to use this API ...
Scott's user avatar
  • 12.2k

1
2 3 4 5
133