A basic plugin – adding link icons

As a demonstration, we will create a simple plugin that adds icons to document links within WordPress. For example, if you create a new post and add a link to an MP3 file in it, it'll look something like the following screenshot:

Once this plugin is complete, the link will look like the following screenshot instead:

To accomplish this, we have to do the following:

  1. Provide images of the icons that will be used
  2. Have a PHP function that identifies the links to documents and adds a special CSS class to them
  3. Have a style sheet that creates the CSS classes for displaying the icons
  4. Tell WordPress that whenever it prints the content of a post (that is, using the the_content() function), it has to run the PHP function first
  5. Tell WordPress to include the new styles in the <head> tag

Keep this list in mind as we move forward. Once all of these five requirements are met, the plugin will be done. So, let's get started!