Creating your own plugin tutorial

At this tutorial you can use our general dynamic plugin template. Please change all class’s names to your own. This way you will make sure there will be no conflicts with other plugins!
We have developed many plugins, and noticed that there are basic functional code parts that almost each plugin needs. This plugin suppose to make plugin development shorter and smoother…
Hope we have managed to help!

Stage 1: Plugin name:

Make sure you rename dynamic directory name and "dynamic.php" to your own.
Change readme.txt file:

=== Dynamic plugin === //Your new plugin name
Contributors: toronetil // Your company
Tags: plugin create, plugin install, plugin directory, plugins debug
Requires at least: 4.0 // WordPress first version you have tested your plugin on
Tested up to: 4.8 // WordPress development version
Stable tag: 1.0 // Last stable tag
License: GPLv2 or later //Keep if you will upload it to WordPress repository
License URI: //Keep if you will upload it to WordPress repository

Editing .php
Edit read section:

Plugin Name: Dynamic //Your plugin name
Plugin URI: // Your plugin url
Description: Dynamic plugin to create your own plugins //Short description
Version: 1.0 // last stable version - trunk and the same tag directory name
Author: Genie Soft //Your company name

Rename internal plugin helper class name:

include_once dirname(__FILE__) .'/Logic/DynamicHelper.php'; //rename here ,the file name and the class name in file

Some help vars example optional. Rename to your own

define('DYNAMIC_VERSION', '1.0');
define( 'DYNAMIC_DB_VERSION', "Version1" );
//Development mode:

Install procedure – rename function, and correct to correct plugin helper class name

register_activation_hook(__FILE__,'Dynamics_install'); //correct to other function name
function Dynamics_install($networkwide) {//correct to other function name
$DynamicHelper = new DynamicHelper();//correct plugin helper class name
$DynamicHelper->Install($networkwide); //implement in class helper. Supports multi site infrastructure

Support adding new blogs on multisite WordPress. Change Dynamic_new_blog to your own. Also in all internal function rename plugin class helper.

add_action( 'wpmu_new_blog', 'Dynamic_new_blog', 10, 6);
function Dynamic_new_blog($blog_id, $user_id, $domain, $path, $site_id, $meta ) {

Don’t forget renaming internal classes calls and names in your plugin helper…

Lets go over general idea in each WordPress trigger (Don’t forget to rename all function names to your unique one’s):

Functionality responsible for uninstalling plugin:
register_deactivation_hook( __FILE__, 'Dynamics_remove' );

Loading scripts and styles:
add_action('wp_enqueue_scripts', 'Dynamic_scripts_method');
add_action('admin_enqueue_scripts', 'Dynamic_scripts_method');

function Dynamic_scripts_method() {

Dealing with ajax request on front pages and at wp-admin:
add_action('wp_ajax_nopriv_DynamicRequest', 'prefix_ajax_DynamicRequest');
add_action('wp_ajax_DynamicRequest', 'prefix_ajax_DynamicRequest');

function prefix_ajax_DynamicRequest()

Loading admin menus:
if ( is_admin() ){
add_action('admin_menu', 'Dynamic_admin_menu');
function Dynamic_admin_menu()

Some content filter:
//content filter
add_filter( 'the_content', 'Dynamic_content_filter', 20 );

function Dynamic_content_filter( $content ) {

Short Codes: to enable inserting in posts and pages:

//translate short tags
function Dynamic_short_func( $atts ) {
$DynamicHelper = new DynamicHelper();
return $DynamicHelper->GetShortcode($atts);

add_shortcode( 'dynamic', 'Dynamic_short_func' );


At this class we have concentrated most useful functions:
Get query from WordPress url

public function getQueryParam($parameter,$url)
$parts = parse_url($url);
parse_str($parts['query'], $query);
return $query[$parameter];

Get WordPress User data by parameter:

public function getUserParam($param)
$user = wp_get_current_user();
case "ID": return $user->ID;
case "user_login": return $user->user_login ;
case "user_email": return $user->user_email ;
case "user_firstname": return $user->user_firstname ;
case "user_lastname": return $user->user_lastname;
case "display_name": return $user->display_name;
return "";

Get WordPress blog info by parameter:

public function getBlogParam($param)
$value = get_bloginfo($param);

return $value;
return "";

Get mysql query results from WordPress database:

public function getResults($query)
global $wpdb;
$myrows = $wpdb->get_results( $query,ARRAY_A );
return $myrows;

Apply mysql query at WordPress database:

public function execute($query)
global $wpdb;
global $wp_error;
if ( $wp_error ) {
return false;
return true;

Get last added row id

public function getLastAddedId()
global $wpdb;
return $wpdb->insert_id;

Send Mail

public static function sendMail($to,$message,$subject)
add_filter('wp_mail_content_type',create_function('', 'return "text/html";'));

Get correct table name at multi-site system:

public function GetTableName($tableName)
global $wpdb;

if (function_exists('is_multisite') && is_multisite()) {
return $wpdb->prefix.$tableName;
return $wpdb->prefix.$tableName;


Get current user role:

function get_current_user_role() {

global $wp_roles;
$current_user = wp_get_current_user();
$roles = $current_user->roles;
$role = array_shift($roles);
return isset($wp_roles->role_names[$role]) ? $wp_roles->role_names[$role] : "guest";
return "guest";

Working with cache

public function getDataFromCache($dataName)
public function saveDataToCache($dataName,$data)