Extending WordPress to Display Music Chords & Lyrics

It plan on extending WordPress to support creating music lead sheets using a ChordPro type syntax. This syntax uses square brackets to enclose tags describing music attributes of a song (eg. [Title], [Composer], [Tempo]) in addition to chord names (eg. [Amaj7]).

It appears that a plug-in can be created which will allow extending WordPress without hacking the source code. Requirements and questions to resolve:

  1. Songs must be easily linkable from multiple locations since songs are used repeatedly and I don’t want to have to cut/paste the song source every time it is used.
  2. Provide all the capability of the current custom PHP songs pages on TheRockBand.org:
    a. Allow display of songs for a given date showing sequence, etc.
    b. Associate with an MP3 file.
    c. Provide alternate displays, for example “List all songs alphabetically”

In addition to providing the existing functionality, it will be good to allow comments/discussions regarding each song, with searchability for previous comments made about a given song.

Plug-In creation steps:

  1. Create name to use for main .php file and folder for additional files
    How about “LeadSheet” or “ChordSheet”?
    This file and folder will need to be copied to wp-content/plugins/ during installation.
  2. Create a readme.txt if I want to publish to wordpress.org/extend/plugins.
  3. Create a homepage for distributing the plugin. Maybe on Lisles.net/LeadSheetPlugin?
  4. Modify main .php file to add plugin API hooks as needed.
  5. Adhere to the WordPress coding standards.
  6. Support Inline Documentation.
  7. Ensure unique names for all functions, etc. Alternatively, encapsulate them in a class.
  8. Do not hardcode “wp_” prefix. Use $spdb->prefix variable instead.
  9. Minimize DB writes.
  10. SELECT only what is needed.
  11. Use add_action in the global execution space to hook actions to new functions.
  12. Use add_filter in the global execution space to hook filters to new functions.
    Data is passed to the new function, and modified data or NULL returned.

It may be better to use a “Page” for each song. Need to investigate how to create and link to pages, etc. The down side may be that Pages don’t use the database, and I like the idea of keeping songs in the database instead of as separate files.

Another possibility is to use a Template Tag.

A plugin Filter might be used to format the ChordPro data prior to display.

A plugin Action might be used to syntax validate a new song upon entry.
This might include allowing cut/paste of existing chord sheets that put chords on a separate line above the lyric lines, and then converting them to ChordPro format.

Provide an Admin display to provide buttons for various chord types and song fields.

Leave a Reply

Your email address will not be published. Required fields are marked *