ChordsAndLyrics WP Plugin

The chords and lyrics WordPress plugin allows the display of formatted chords sheets.
Chord symbols such as C#m or Bb7 within square brackets can be embedded inline with lyric text.
When displayed within a [chordsandlyrics] …. [/chordsandlyrics] block, the chord symbols will be displayed on a line above the text at the point where it appeared.

Test Song Post

I’m currently updating the Chords and Lyrics WordPress plugin.
This is just a copy of the test-song page used for testing it.

Song Title

This is text before chordsandlyrics.

C 
This is the  
F 
first 
 
line.
C 
This is the  
G 
second 
 
line.
Amaj7 
And 
 
 
Bmin 
this 
 
 
C 
is 
 
 
Dsus 
 
 
Eaug 
line 
 
 
Fdim 
with 
 
 
G#/B 
lots 
 
 
Amaj7/C 
of 
 
 
B 
chords.
C 
And this is a line with only three chords but a lot of words packed into it.  
F 
It should have probably been split into two lines.  
G 
It seems to just keep running on and on.

Ending

G 
The 
 
 
C 
end.

This section specifies size=”small”:

C 
This is the  
F 
first 
 
line.
C 
This is the  
G 
second 
 
line.
Amaj7 
And 
 
 
Bmin 
this 
 
 
C 
is 
 
 
Dsus 
 
 
Eaug 
line 
 
 
Fdim 
with 
 
 
G#/B 
lots 
 
 
Amaj7/C 
of 
 
 
B 
chords.
C 
And this is a line with only three chords but a lot of words packed into it.  
F 
It should have probably been split into two lines.  
G 
It seems to just keep running on and on.

Ending

G 
The 
 
 
C 
end.

This is text following chordsandlyrics.
(C)Copyright 2008-2010, Ron Lisle. All rights reserved.

Chords and Lyrics WP plugin Public Release v1.3

I’ve submitted the form to WordPress.org requesting access to their svn to release the Chords and Lyrics publicly.

I’ve removed the old widget, and replaced it with an options page in the Users admin menu. Since this is per-user configurable, I thought that the Users menu was the correct place. But upon rethinking this, I think the correct place is under Appearance. I can easily move it if someone explains to me why another menu would be better 🙂

I’ll post an update when it goes live.

Updated ChordsAndLyrics Plugin

I’ve been using the plugin now for a couple months on our church band website with pretty good success. I’m working now on posting it publicly.

I’ve created a folder for it at http://lisles.net/ChordsAndLyrics.

I’ve also created a new category for specifically discussing it on this blog, and will use that category in links back to this blog regarding it.

The latest version 1.2 contains a Site Admin panel in Settings that can be used to select whether to display both Chords and Lyrics or Lyrics only. It also resolves the problem of lyrics wrapping around under a single Chord symbol when the lyrics length is long.

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.

Music & Lyrics WordPress Theme

Following some additional study of WordPress, it appears that what I am trying to accomplish can be done by creating a Theme.

WordPress Themes

A Theme is simply a collection of custom Template files.

WordPress Templates

A Template file is simply a modified version of the wp-content/index.php file. Templates can be created to modify the way that specific categories are displayed.

So songs can be displayed in chord/lyric format by assigning them a specific category such as “Song”, and then creating a template for that category to format the chord/lyric display (category-X.php).

Similarly, I should be able to create a category and template for the weekly song lineup.

Thoughts on using WordPress for posting lyrics/chords

After further research and thinking, it appears that song sheets could be posted using a “Songs” category.

Posting Songs

A full song listing could then be displayed by selecting the “Songs” category. A custom template could be created to display them by title, artist, etc. and to also format them more compactly. MP3 files could be attached, and a plugin used to allow direct playback (like the 1-bit plugin).

The LeadSheet plugin will be needed to format lyrics/chords into a table to align and format them in ChordPro-like format.

Posting Lineups

Lineups can be handled in either of a couple ways:

  1. Create posts with the Lineup date in the title and category of “Lineups”. Like songs, these could be displayed using a custom template. A shortcode could be used to provide links to each associated song post. The benefit of this approach is that each lineup post could have discussions using comments.
  2. A custom page could be created to interface with a MySQL table to provide dynamic lineup data. I don’t think this approach would allow comments unless custom coded into the page template.

Action Items

I think I’ll pursue option 1. Items needed to implement this are:

  • Template for “Lineup” list and single category display.
    List could expand the upcoming date automatically, and optionally be used as the front page.
  • Plug-In to expand and format ChordPro.
  • ShortCode for use on Lineup posts to locate songs by name and display links to song posts.
    ShortCode could give song name, and an intelligent search used to locate song posts and MP3 media and provide one or more links to them. For example the shortcode [song name=”Here to Worship”] would result in <a href=”index.php?p=###>Lyrics</a> …
  • Page and template to display song usage:
    This would query to identify which songs have been played and how many times for any specified year. The CCLI # should be associated and displayed with each song also.

WordPress Links Not Working

The category links, among others, are not working. I believe that the problem is related to permalinks, which require .htaccess be modified. This appears to only be happening on my local server and not on the remote server. I need to look into this, but it’s a low priority since the remote server appears to be working ok.