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.
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
Perfectly composed subject material, Really enjoyed
looking through.
Thank you Lettie
What’s up, yup this post is in fact nice and I have learned lot of things
from it about blogging. thanks.
Thank you