Articles of plugin development

Database “Migration” for Plugins?

I’m creating a plugin for WordPress. This plugin will need to save data to the database. In other programming frameworks I’ve worked with, there are systems called “database migrations”. These migrations are SQL ALTER TABLE or CREATE TABLE statements/scripts Sometimes abstracted into the programming language of the framework Written and stored in a common way […]

WordPress add_admin_page not working even parameters are correct?

function Y_add_admin_page(){ add_menu_page(‘Y-07 Theme Options’,’Y-07′,’mange_options’,’y-admin’,’Y_admin_create’,”,110); } add_action(‘admin_menu’,’Y_add_admin_page’); I had used is_admin function it is returning false even I am an adminstrator

Will simple function names in a class structure conflict with other plugins?

I implement a class structure in my plugin, for example: class Ethans_Plugin { public function __construct() { add_filter( ‘admin_init’, array( $this, ‘admin’ ), 10, 1 ); add_action( ‘admin_footer’, array( $this, ‘footer’ ), 10, 1 ); } public function admin() { # code here… } public function footer() { # code here… } } When I […]

Which functions in theme or plugin load first

I created a plugin to override a theme’s function. As I learn that function in plugin loads first but I got an error Fatal error: Cannot redeclare wooc_extra_register_fields() (previously declared in ****/themes/****/functions.php:247) in ***/plugins/custom-plugin/custom-plugin.php on line 89 Not sure what I am doing wrong. Also put theme’s functions need to be override in if !function […]

Symlinked plugin directory doesn't appear in Admin

I have a simple test plugin – a folder called tester containing a file called tester.php that contains only this: <?php /* Plugin Name: My tester */ ?> I have a copy of WordPress running locally on my Mac. When the plugin is in the plugins directory it appears in the Admin list of plugins. […]

Can I get all options using the option group id?

I would like to return all the option that I registered under a specific group id. Is there a way to do this?

Should I always prefer esc_attr_e & esc_html_e instead of _e?

I am working to internationalize my plugin. As I can see on WordPress site about esacaping, it says you should always use it. But as I can see in many popular plugins, they have used _e instead apart from few specific cases. So should I always use escaping or not for all strings, if not […]

call_user_func_array() expects parameter 1 to be a valid callback, array must have exactly two members

I am trying to create a theme option page in my plugin. I have pasted below the entire code. But it is giving an error : call_user_func_array() expects parameter 1 to be a valid callback, array must have exactly two members class KD_Options { public function __construct(){ $this->register_settings_and_fields(); } public function add_menu_page(){ add_options_page(‘Theme Options’,’Theme Options’,’administrator’,__FILE__, […]

Does flush_rewrite_rules() remove all rules added by other plugins as well as mine?

I am developing a plugin, and am using add_rewrite_rule followed by flush_rewrite_rules during plugin activation. On plugin deactivation I am using just flush_rewrite_rules to remove the rule that I had added. Now let’s assume another plugin had also added a rewrite rule. Would calling flush_rewrite_rules not remove this other plugins rewrite rule as well, even […]

Is dynamic forms/entries possible in Widget?

I am new to WordPress Plugins development, and I just started working with the widget. My question is: What are the limitations of WordPress Widget? I tried to use jQuery to make the Widget Form more interactive/dynamic, but it doesn’t seem to work at all. For example, I have a button that when clicked will […]