Getting started with WordPressget_bloginfo()Enqueuing scriptsMaking network requests with HTTP APIEnqueuing Styleshome_url()Custom Post Typestemplate_includeThe Loop (main WordPress loop)AJAXThe $wpdb ObjectActions and Filterswp_get_current_user()Add/remove contact info for users with user_contactmethods filter hookCreating a custom templateCustomizer Hello WorldCustomizer Basics (Add Panel, Section, Setting, Control)The Admin Bar (aka "The Toolbar")Querying postsAlternating main loop (pre_get_posts filter)ShortcodeCreate a Post Programmaticallyget_template_part()Taxonomiesget_template_part()ShortcodesPost FormatsCustom exerpts with excerpt_length and excerpt_morePlugin developmentSecurity in WordPress - EscapingTemplate hierarchyRemove Version from Wordpress and StylesheetsChild Theme Basicsadd_action()get_template_part()Shortcode with attributeSidebarsSecurity in WordPress - SanitizationinitCreate Template for Custom Post TypeFunction: add_action()Add ShortcodeHow Can I integrate Markdown editor with Advance Custom Field's repeater Add-on.Installation and Configurationwp_get_current_user()WP-CronSecure your installationOptions APIFunction : wp_trim_words()WP_Query() LoopUpdate WordPress ManuallyThemesWP-CLIDebuggingadd_menu_page()add_submenu_page()get_option()get_permalink()get_the_category()the_title()get_the_title()add_editor_style()add_theme_support()WordPress Plugin creationRun WordPress local with XAMPPAdmin Dashboard WidgetsSite MigrationMeta BoxRemove Auto Line Breaks From Content and Excerptget_home_path()Wordpress theme and child-theme developmentREST API

WordPress Plugin creation

Other topics

Minimal Setup of a Plugin Folder and Files

First step of creating a plugin is creating the folder and file which the plugin will load from.

Plugins are located in /wp-content/plugins/.

The WordPress standard is to create a folder and filename that mirror each other like so:

/wp-content/plugins/myplugin/
/wp-content/plugins/myplugin/myplugin.php

After creating your plugin file you need to start your plugin with a Plugin Header. This allows WordPress to scan your plugin file and store the meta data about the plugin, and allow users to use this and determine if they want your plugin active, or inactive. Copy this template into the top of your main plugin file you created, and modify it as needed:

<?php
/**
 * Plugin Name: PLUGIN-NAME
 * Plugin URI: HTTP-LINK-TO-WEBSITE-PLUGIN-PAGE-OR-REPO
 * Description: BREIF DESCRIPTION - KEEP IT SHORT
 * Author: WORDPRESS-DOT-ORG-USERNAME
 * Version: 0.0.1
 * Author URI: HTTP-LINK-TO-MAINTAINER
 * License: GNU General Public License v2 or later
 * License URI: http://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: short_prefix
 */

// Begin custom PHP WordPress plugin work

Note that WordPress plugins should typically be licensed as GPL. Licensing should not be discussed as part of this topic though.

At this point, you should already by able to see your new plugin in the WordPress Admin area. In a standard setup you would locate this area at /wp-admin/plugins.php. Go ahead and activate your plugin, and you are ready move into the next steps of building your plugin!

Just to end our example on something actionable, you could now add the following to the bottom of your plugin file:

die('My custom plugin is loaded : '. __FILE__);

Refreshing your site after this change should result in all pages printing this text. Never do this in production (live) sites, and always remember to take this back out before continuing.

Contributors

Topic Id: 9420

Example Ids: 29189

This site is not affiliated with any of the contributors.