Thord Daniel Hedengren - Smashing WordPress_ Beyond the Blog-Wiley (2014)

(avery) #1

180 PART III • Using Plugins with WordPress


Before you move on with plugin basics, you should know that writing plugins is
usually a lot more demanding than working with WordPress themes. You need a
firm knowledge of PHP, so if you’re lacking that, I suggest you brush up on your skills
before embarking on any large plugin writing adventure.

Giving your plugin a unique filename or folder name is very important because plugins reside
in wp-content/plugins/, and you don’t want any conflicts. Name it appropriately, and in such a
way that there is no doubt which plugin it is should someone need to find it using FTP who
knows it only by the name displayed in the WordPress admin interface.

The identifying plugin header block will look familiar. The following is a dummy:

<?php
/*
Plugin Name: My Smashing Plugin
Plugin URI: http://my-smashing-plugin-url.com/
Description: This is what my Smashing Plugin actually does.
Version: 1.0
Author: Thord Daniel Hedengren
Author URI: http://tdh.me/
*/
?>

Actually, only the plugin name line, the first one within the comment notations, is mandatory.
The rest should be there, however, so that the user knows what the plugin is, where to get
updates, version numbering, who made it, and so on.

You should include licensing information as well. This is the standard GPL licensing info
dummy text that is recommended in the WordPress Codex:

<?php
/* Copyright YEAR PLUGIN_AUTHOR_NAME (e-mail : PLUGIN AUTHOR E-MAIL)

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
?>
Free download pdf