Asked 7 years ago
22 May 2017
Views 1232
sachin

sachin posted

how to make wordpress plugin ?

how to make wordpress plugin ? i am newbie at wordpress plugin . i found some help at documentation but still not more help how to make wordpress plugin
Mitul Dabhi

Mitul Dabhi
answered Nov 30 '-1 00:00

simply create folder(your-plugin-name) in wp-content/plugins

and create php file named same with your-plugin-name.php

header is must in landing file of the plugin like below


<?php
/*
Plugin Name:  Your plugin name
Plugin URI:  https://your-website.com
Description: Your plugin description
Version:     1/0
Author:      Your name and your email id
Author URI:  https://your-website.com
 */


above is needed parameter for the header of the plugin file.
i skipped some.check more

and now you start the code at main file.
you can create more folder for admin or css or js
you can put the code at separate for admin and frontend

How to admin
use is_admin function to separate run for admin

if ( is_admin() ) {
    // we are in admin 
   $dir = plugin_dir_path( __FILE__ );
    require_once( $dir. '/admin/admin-loader.php' );
}


admin/admin-loader.php never load untill we are in admin

Shortcode


add_shortcode( "my-short-code-label",'functionName');
function functionName(){
// so we are in short code 
}


include [my-short-code-label] at post or page to include the code at functionName function




Post Answer