Best Practices – WordPress Plugin Making

How to add custom meta title and meta description in Wordpress?

Hello to all, welcome to therichpost.com. In this post, I will tell, Best Practices – WordPress Plugin Making.

WordPress is the top CMS in the world and I personally like it very much.

Today I am going to tell, how wordpress plugin will make with proper wordpress standards.

In this post, I will create plugin folder->  files->  classes-functions-shortcode-hooks->  zip->  uploadAdmin->  getShortcode.

Best Practices - WordPress Plugin Making

 

Here are the working and tested code for Best Practices WordPress Plugin Making:

 

1. Very First make a  folder named ‘wp-rich-text’.
2. Second, create ‘wp-rich-text.php’ file in ‘wp-rich-text’ folder and below code into it:

This is the main file of plugin, in which we declare plugin info and other methods:

<?php
/**
 * Plugin Name: Rich Plugin
 * Plugin URI: #
 * Description: #
 *
 */

define( 'RICH_PLUGIN_DIR' , plugin_dir_path( __FILE__ ));//For calling the files
if(!class_exists('RichData')){
  require_once( RICH_PLUGIN_DIR. 'class.rich.php' );
}
?>

 

3. Next, create, ‘class.rich.php’ file in wp-rich-text’ folder and below code into it:

In this file, we create class and its functions and wordpress hooks:

<?php
/*
Plugin classes
*/
class RichData{

  public static function init() {

        function custom_text( $atts ){
            return "test";
        }
        add_shortcode( 'RichText', 'custom_text' );//create shortcode to call the function into admin pages and theme's template files
    }
}
add_action( 'init', array( 'RichData', 'init' ));
?>
4. Now files and folder structure have been done now make a zip of ‘wp-rich-text’ and upload it from add plugin section into your wordpress dashboard.

 

5. To call the plugin functionality, we need to add shortcode into our wp-admin posts, pages or theme’s templates files:
// Call the shortcode into wp-admin posts and pages with below code
[RichText]


//Call the shortcode into theme's templates files with below code
echo do_shortcode('[RichText]');

 

This is done with basic plugin marking tips in wordpress. if you have any query related to it then do comment below or ask questions.

Code Is Poetry,

Thank you,

Therichpost

 

 

 

Comments

4 responses to “Best Practices – WordPress Plugin Making”

  1. Lettie Edmunds Avatar
    Lettie Edmunds

    Perfectly composed subject material, Really enjoyed
    looking through.

    1. Ajay Malhotra Avatar

      Thank you Lettie

  2. 66ceme Avatar
    66ceme

    What’s up, yup this post is in fact nice and I have learned lot of things
    from it about blogging. thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.