Plugin Development

Tutorials & Developer Docs+

developer.wordpress.org/plugins/intro/


makitweb.com/how-to-create-simple-wordpress-plugin/


Disable/Enable All WordPress Plugins via the Database

An Article by www.hostgator.com


Wordpress Plugin Development tutorial from scratch (Part 1) Wordpress plugin basics and introduction

Video Tuts Series by Online Web Tutor - Nov 7, 2017


Wordpress Hooks Tutorial for beginners from scratch #1 Introduction, Type of hooks, Syntax, Examples

Video Tuts Series by Online Web Tutor - Oct 26, 2018


Wordpress Plugin Development Series by Alessandro Castellani

Video Tuts Series- Nov 10, 2017


WordPress Plugin Development Bangla tutorial from scratch -- Plugin Start - 1

Video Tuts Series by Smart Coder - Oct 3, 2017


Basic WordPress Plugin Development - Playlist

Video Tuts series by Robiz show - Feb 28, 2020


Code with mehedi Channel


1 - Structuring of your WordPress Plugin | বাংলায় ওয়ার্ডপ্রেস ডেভেলপমেন্ট by Tareq Hasan

Video Tuts series by Tareq Hasan - Mar 1, 2020


knowthecode.io/docx/wordpress/apply_filters


WordPress Hooks Actions and Filters Introduction Full Playlist Part -1

Video Tuts Series by Imran Sayed - Nov 4, 2017



Build a Custom WordPress User Flow — Part 1: Replace the Login Page


Customising the WordPress User Profile Page without plugins

by craigedmonds | 18 Apr, 2020


How to remove WordPress admin Profile page fields

(Including Personal Options, Biographical Info, Website etc.) and titles without JS


adding custom stylesheet to wp-admin

wordpress.stackexchange.com/questions/110895/adding-custom-stylesheet-to-wp-admin


css-tricks.com/snippets/wordpress/apply-custom-css-to-admin-area/



Knowledgebase+

To get started creating a new plugin, follow the steps below.

  1. Navigate to the WordPress installation’s wp-content directory.
  2. Open the plugins directory.
  3. Create a new directory and name it after the plugin (e.g. plugin-name).
  4. Open the new plugin’s directory.
  5. Create a new PHP file (it’s also good to name this file after your plugin, e.g. plugin-name.php).

you’ll need to add a plugin header comment. This is a specially formatted PHP block comment that contains metadata about the plugin, such as its name, author, version, license, etc. The plugin header comment must comply with the header requirements, and at the very least, contain the name of the plugin.

<?php
/**
 * Plugin Name: YOUR PLUGIN NAME
 */
<?php
/**
 * Plugin Name:       My Basics Plugin
 * Plugin URI:        https://example.com/plugins/the-basics/
 * Description:       Handle the basics with this plugin.
 * Version:           1.10.3
 * Requires at least: 5.2
 * Requires PHP:      7.2
 * Author:            John Smith
 * Author URI:        https://author.example.com/
 * License:           GPL v2 or later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       my-basics-plugin
 * Domain Path:       /languages
 */
The deactivation hook is sometimes confused with the uninstall hook. The uninstall hook is best suited to delete all data permanently such as deleting plugin options and custom tables, etc.

Activation

register_activation_hook( __FILE__, 'pluginprefix_function_to_run' );

Deactivation

register_deactivation_hook( __FILE__, 'pluginprefix_function_to_run' );

The first parameter in each of these functions refers to your main plugin file, which is the file in which you have placed the plugin header comment. Usually these two functions will be triggered from within the main plugin file; however, if the functions are placed in any other file, you must update the first parameter to correctly point to the main plugin file.

WP_Query+


Wordpress WP_Query Tutorial for beginners from scratch (Part#1) | About WP_Query and standard use

Video Tuts series by Online Web Tutor - Dec 30, 2018


// WP_Query which displays posts from movies category:
$the_query = new WP_Query( 'category_name=movies' );
 
// The Loop
if ( $the_query->have_posts() ) {
        echo '<ul>';
    while ( $the_query->have_posts() ) {
        $the_query->the_post();
        echo '<li>' . get_the_title() . '</li>';
    }
        echo '</ul>';
} else {
    // no posts found
}
/* Restore original Post Data */
wp_reset_postdata();

github.com/sultann/wp-query-builder/>

pressidium.com/blog/create-wordpress-custom-post-types-manually/


pressidium.com/blog/wordpress-custom-post-types-taking-it-further/


pressidium.com/blog/create-wordpress-custom-post-types-using-your-own-plugin/






Admin Menu+

Add a top-level menu page:



add_menu_page( 
	string $page_title, 
	string $menu_title, 
	string $capability, 
	string $menu_slug, 
	callable $function = '', 
	string $icon_url = '', 
	int $position = null 
	)

page_title: The title of the page.
menu_title: Menu title that will be displayed on the dashboard.
capability: Minimum capability to view the menu.
menu_slug: Unique name used for the menu item.
function:  Used to display page content.
icon_url: URL to custom image used as an icon.
position: Location in the menu order.

This function takes a capability which will be used to determine whether or not a page is included in the menu. The function which is hooked in to handle the output of the page must check that the user has the required capability as well.


Parameters

$page_title

(string) (Required) The text to be displayed in the title tags of the page when the menu is selected.

$menu_title

(string) (Required) The text to be used for the menu.

$capability

(string) (Required) The capability required for this menu to be displayed to the user.

$menu_slug

(string) (Required) The slug name to refer to this menu by. Should be unique for this menu page and only include lowercase alphanumeric, dashes, and underscores characters to be compatible with sanitize_key().

$function

(callable) (Optional) The function to be called to output the content for this page.

Default value: ''

The function that displays the page content for the menu page.
Technically, the function parameter is optional, but if it is not supplied, then WordPress will basically assume that including the PHP file will generate the administration screen, without calling a function. The page-generating code can be written in a function within the main plugin file.
In the event that the function parameter is specified, it is possible to use any string for the menu_slug parameter. This allows usage of pages such as ?page=my_super_plugin_page instead of ?page=my-super-plugin/admin-options.php.
The function must be referenced in one of two ways:
  1. if the function is a member of a class within the plugin it should be referenced as array( $this, 'function_name' )
  2. in all other cases, using the function name itself is sufficient
 
$icon_url

(string) (Optional) The URL to the icon to be used for this menu.
* Pass a base64-encoded SVG using a data URI, which will be colored to match the color scheme. This should begin with 'data:image/svg+xml;base64,'.
* Pass the name of a Dashicons helper class to use a font icon, e.g. 'dashicons-chart-pie'.
* Pass 'none' to leave div.wp-menu-image empty so an icon can be added via CSS.

Default value: ''

$position

(int) (Optional) The position in the menu order this one should appear.

Default value: null


Menu Structure:


To add an administration menu, you must do three things:


  1. Create a function that contains the menu-building code
  2. Register the above function using the admin_menu action hook. (If you are adding an admin menu for the Network, use network_admin_menu instead).
  3. Create the HTML output for the page (screen) displayed when the menu item is clicked

It is that second step that is often overlooked by new developers. You cannot simply call the menu code described; you must put it inside a function, and then register the function.


Add Submenu page

add_submenu_page( 
			string $parent_slug, 
			string $page_title, 
			string $menu_title, 
			string $capability, 
			string $menu_slug, 
			callable $function = '' 
			)

Slugs for $parent_slug (first parameter)

Dashboard: ‘index.php’
Posts: ‘edit.php’
Media: ‘upload.php’
Pages: ‘edit.php?post_type=page’
Comments: ‘edit-comments.php’
Custom Post Types: ‘edit.php?post_type=your_post_type’
Appearance: ‘themes.php’
Plugins: ‘plugins.php’
Users: ‘users.php’
Tools: ‘tools.php’
Settings: ‘options-general.php’
Network Settings: ‘settings.php’

  1. For Dashboard: add_submenu_page('index.php',...)
  2. For Posts: add_submenu_page('edit.php',...)
  3. For Media: add_submenu_page('upload.php',...)
  4. For Pages: add_submenu_page('edit.php?post_type=page',...)
  5. For Comments: add_submenu_page('edit-comments.php',...)
  6. For Custom Post Types: add_submenu_page('edit.php?post_type=your_post_type',...)
  7. For Appearance: add_submenu_page('themes.php',...)
  8. For Plugins: add_submenu_page('plugins.php',...)
  9. For Users: add_submenu_page('users.php',...)
  10. For Tools: add_submenu_page('tools.php',...)
  11. For Settings: add_submenu_page('options-general.php',...)

Determining Location for New Menus


Adding a submenu page to a custom post type

If you want to add a submenu type to a custom post type, such as a reference page for a custom post type created by a plugin, you can use for the $parent_slug parameter whatever you see up top on the “All Posts” view for that post type. For instance, for a custom post type “Book,” the $parent_slug could be 'edit.php?post_type=book'.

/**
 * Adds a submenu page under a custom post type parent.
 */
function books_register_ref_page() {
    add_submenu_page(
        'edit.php?post_type=book',
        __( 'Books Shortcode Reference', 'textdomain' ),
        __( 'Shortcode Reference', 'textdomain' ),
        'manage_options',
        'books-shortcode-ref',
        'books_ref_page_callback'
    );
}
 
/**
 * Display callback for the submenu page.
 */
function books_ref_page_callback() { 
    ?>
    <div class="wrap">
        <h1><?php _e( 'Books Shortcode Reference', 'textdomain' ); ?></h1>
        <p><?php _e( 'Helpful stuff here', 'textdomain' ); ?></p>
    </div>
    <?php
}

Submenu with PHP Class

/**
 * Sub menu class
 */
class Sub_menu {
 
    /**
     * Autoload method
     * @return void
     */
    public function __construct() {
        add_action( 'admin_menu', array(&$this, 'register_sub_menu') );
    }
 
    /**
     * Register submenu
     * @return void
     */
    public function register_sub_menu() {
        add_submenu_page( 
            'options-general.php', 'Submenu title', 'Submenu title', 'manage_options', 'submenu-page', array(&$this, 'submenu_page_callback')
        );
    }
 
    /**
     * Render submenu
     * @return void
     */
    public function submenu_page_callback() {
        echo '<div class="wrap">';
        echo '<h2>Submenu title</h2>';
        echo '</div>';
    }
 
}
 
new Sub_menu();

Dashicons for Admin Menu

The wpdb Class+

codex.wordpress.org/Class_Reference/wpdb


developer.wordpress.org/reference/classes/wpdb/


WORDPRESS DATA VALIDATION INSERT DATA USING $wpdb prepare( )

Video Tuts by Imran Sayed - Oct 21, 2017




//absolute path to wp-load.php, or relative to this script
//e.g., ../wp-core/wp-load.php
include( 'trunk/wp-load.php' ); 

//grab the WPDB database object, using WP's database
//more info: http://codex.wordpress.org/Class_Reference/wpdb
global $wpdb;

//make a new DB object using a different database
//$mydb = new wpdb('username','password','database','localhost');

//basic functionality

//run any query
$wpdb->query( "SELECT * FROM wp_posts" );

//run a query and get the results as an associative array
$wpdb->get_results( "SELECT * FROM wp_posts" );

//get a single variable
$wpdb->get_var( "SELECT post_title FROM wp_posts WHERE ID = 1" );

//get a row as an assoc. array
$wpdb->get_row( "SELECT * FROM wp_posts WHERE ID = 1" );

//get an entire column
$wpdb->get_col( "SELECT post_title FROM wp_posts" );

WP_List_Table+

developer.wordpress.org/reference/classes/wp_list_table/


Concept of WP_List_Table in wordpress for beginners from scratch - Introduction, Class File, Methods

Video Tuts Series by Online Web Tutor - Oct 7, 2018


supporthost.com/wp-list-table-tutorial/


vijayan.in/how-to-create-custom-table-list-in-wordpress-admin-page/


smashingmagazine.com/2011/11/native-admin-tables-wordpress/


pressidium.com/blog/customizing-wordpress-admin-tables-getting-started/


wpengineer.com/2426/wp_list_table-a-step-by-step-guide/



How to Load WordPress Post With AJAX+

artisansweb.net/load-wordpress-post-ajax/


How To Use jQuery Ajax In WordPress

Video Tuts by Artisans Web - Jan 5, 2015



How To Set Featured Image Programmatically In WordPress+

artisansweb.net/set-featured-image-programmatically-wordpress/




React with Wordpress+

React with WordPress | React WordPress tutorial |

Video Tuts Series by Imran Sayed - May 20,2019




Wordpress API & WP REST API+

codex.wordpress.org/WordPress_APIs


Wordpress JSON REST API Tutorial for beginners in HINDI(#1) Introduction, WP JSON, JSON API call

Video Tuts Series by Online Web Tutor - Jun 15, 2018


WordPress REST API Tutorial (Real Examples)

Video Tuts by LearnWebCode - Dec 15 - 2016


What is REST API ? How to use ?- REST API Bangla tutorial

Video Tuts by Code With Mehedi - Apr 28, 2020




 +




© 2025 My Wordpress collection by Mizanur Rahman