Photo by Justin Morgan on Unsplash

Writing a Simple WordPress Plugin: The Basics

What You Need to Write a WordPress Plugin

How to Write a Simple WordPress Plugin

Creating the Main File

Adding Functions

<?php
/**
* Hot Recipes
*
* @bundle HOTRECIPES
* @creator Freddy
* @license gplv2-or-later
* @model 1.0.0
*
* @wordpress-plugin
* Plugin Name: Hot Recipes
* Plugin URI: https://vistamedia.me
* Description: The Hot Recipes WordPress plugins provides a {custom} submit sort appropriate for eating places.
* Version: 1.0.0
* Author: Freddy
* Author URI: https://vistamedia.me
* Text Domain: hot-recipes
* Domain Path: /languages
* License: GPLv2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
*
* You ought to have acquired a copy of the GNU General Public License
* together with Hot Recipes. If not, see <https://www.gnu.org/licenses/gpl-2.0.html/>.
*/
// Exit if accessed straight.
if ( ! outlined( 'ABSPATH' ) ) exit;
// Plugin title
outline( 'HOTRECIPES_NAME', 'Hot Recipes' );
// Plugin model
outline( 'HOTRECIPES_VERSION', '1.0.0' );
// Plugin Root File
outline( 'HOTRECIPES_PLUGIN_FILE', __FILE__ );
// Plugin base
outline( 'HOTRECIPES_PLUGIN_BASE', plugin_basename( HOTRECIPES_PLUGIN_FILE ) );
// Plugin Folder Path
outline( 'HOTRECIPES_PLUGIN_DIR', plugin_dir_path( HOTRECIPES_PLUGIN_FILE ) );
// Plugin Folder URL
outline( 'HOTRECIPES_PLUGIN_URL', plugin_dir_url( HOTRECIPES_PLUGIN_FILE ) );
/**
* Load the primary class for the core performance
*/
require_once HOTRECIPES_PLUGIN_DIR . 'core/class-hot-recipes.php';
/**
* The major perform to load the one occasion
* of our grasp class.
*
* @creator Freddy
* @since 1.0.0
* @return object|Hot_Recipes
*/
perform HOTRECIPES()
return Hot_Recipes::occasion();
HOTRECIPES();
/**
* Registers the recipes submit sort.
*/
perform hot_recipes_register_post_types()
add_action( 'init', 'hot_recipes_register_post_types' );

Compress Your Plugin Folder

Logo

更多推荐