WordPress Plugin Development

Header Requirements

As described in Getting Started, the header comment is what tells WordPress that a file is a plugin.

At a minimum, a header comment must contain the Plugin Name, but several pieces can – and usually should – be included:

  • Plugin Name: (required) The name of your plugin, which will be displayed in the Plugins list in the WordPress Admin.
  • Plugin URI: The home page of the plugin, which might be on WordPress.org or on your own website. This must be unique to your plugin.
  • Description: A short description of the plugin, as displayed in the Plugins section in the WordPress Admin. Keep this description to fewer than 140 characters.
  • Version: The current version number of the plugin, such as 1.0 or 1.0.3. Alert: When assigning a version number to your project, keep in mind that WordPress uses the PHP version_compare() function to compare plugin version numbers. Therefore, before you release a new version of your plugin, you should make sure that this PHP function considers the new version to be “greater” than the old one.  For example, 1.02 is actually greater than 1.1.
  • Author: The name of the plugin author. Multiple authors may be listed using commas.
  • Author URI: The author’s website or profile on another website, such as WordPress.org.
  • License: The short name (slug) of the plugin’s license (e.g. GPL2). More information about licensing can be found in the WordPress.org guidelines.
  • License URI: A link to the full text of the license (e.g. https://www.gnu.org/licenses/gpl-2.0.html).
  • Text Domain: The gettext text domain of the plugin. More information can be found in the Text Domain section of the How to Internationalize your Plugin page.
  • Domain Path: The domain path let WordPress know where to find the translations. More information can be found in the Domain Path section of the How to Internationalize your Plugin page.

A valid PHP file with a header comment might look like this:

Plugin Name: WordPress.org Plugin
Plugin URI:  https://developer.wordpress.org/plugins/the-basics/
Description: Basic WordPress Plugin Header Comment
Version:     20160911
Author:      WordPress.org
Author URI:  https://developer.wordpress.org/
License:     GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: wporg
Domain Path: /languages


function pegasus_carousel_menu_item() {
		add_menu_page("Carousel", "Carousel", "manage_options", "pegasus_carousel_plugin_options", "pegasus_carousel_plugin_settings_page", null, 99);
		add_submenu_page("pegasus_carousel_plugin_options", "Shortcode Usage", "Usage", "manage_options", "pegasus_carousel_plugin_shortcode_options", "pegasus_carousel_plugin_shortcode_settings_page" );
	add_action("admin_menu", "pegasus_carousel_menu_item");

	function pegasus_carousel_plugin_settings_page() { ?>
	    <div class="wrap">
		<form method="post" action="options.php">
	function pegasus_carousel_plugin_shortcode_settings_page() { ?>
		<div class="wrap pegasus-wrap">
			<h1>Shortcode Usage</h1>
			<p>Logo Slider Usage: <pre>[logo_slider]</pre></p>
			<p>Logo Slider Usage: <pre>[logo_slider the_query="post_type=logo_slider&showposts=100&order_by=title&order=ASC"]</pre></p>
			<p>Testimonial Slider Usage: <pre>[testimonial_slider image="circle" type="bubble" class="test" the_query="post_type=testimonial&showposts=100" ]</pre></p>
			<p style="color:red;">MAKE SURE YOU DO NOT HAVE ANY RETURNS OR <?php echo htmlspecialchars('<br>'); ?>'s IN YOUR SHORTCODES, OTHERWISE IT WILL NOT WORK CORRECTLY</p>
	function enable_logo_slider_cpt() { ?>
		<input name="chk_slider_cpt" type="checkbox" value="1" <?php checked(1, get_option('chk_slider_cpt'), true); ?> />
	function enable_testimonial_cpt() { ?>
		<input name="chk_testimonial_cpt" type="checkbox" value="1" <?php checked(1, get_option('chk_testimonial_cpt'), true); ?> />
	function display_carousel_plugin_panel_fields() { 
		add_settings_section("section", "Shortcode Settings", null, "theme-options");
		add_settings_field("chk_slider_cpt", "Enable Logo Slider Custom Post Type", "enable_logo_slider_cpt", "theme-options", "section");
		add_settings_field("chk_testimonial_cpt", "Enable Testimonial Custom Post Type", "enable_testimonial_cpt", "theme-options", "section");

		register_setting("section", "chk_slider_cpt");
		register_setting("section", "chk_testimonial_cpt");
	add_action("admin_init", "display_carousel_plugin_panel_fields");
  • web_development/wordpress/plugin-dev.txt
  • Last modified: 2020/10/09 04:02
  • by jimboobrien