Plugin Directory

Changeset 3087130


Ignore:
Timestamp:
05/15/2024 12:22:31 PM (23 months ago)
Author:
rlisle
Message:

v2.0 separate options for lyrics-only and european

Location:
chords-and-lyrics/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • chords-and-lyrics/trunk/ChordsAndLyrics.php

    r1860019 r3087130  
    33 * @package Chords_And_Lyrics
    44 * @author  Ron Lisle
    5  * @version 1.7
     5 * @version 2.0
    66 */
    77/*
     
    99Plugin URI: http://Lisles.net/
    1010Description: This plugin assists in the creation of staffless lead sheets.
    11 Version: 1.7
     11Version: 2.0
    1212Author: Ron Lisle
    1313Author URI: http://Lisles.net
     
    1515Refer to Readme.txt file for more information.
    1616
    17 Copyright 2008-2012 Ron Lisle
     17Copyright 2008-2024 Ron Lisle
    1818
    1919This program is free software; you can redistribute it and/or modify
     
    4040
    4141function chordsandlyrics_settings_init(){
    42     global $userdata;
    43     wp_get_current_user();
    44     $user_settings_name = 'cnl_setting_values_for_' . $userdata->user_login;
     42    $setting_prefix = cnl_setting_prefix();
    4543    add_settings_section('cnl_setting_section','Chords and Lyrics Options','cnl_setting_section','reading');
    4644    add_settings_field('lyrics-only','Display chords or lyrics only?','cnl_lyrics_only_enabled',
     
    4846    add_settings_field('european-chords','Display European chords?','cnl_european_chords_enabled',
    4947                    'reading','cnl_setting_section');
    50     register_setting('reading',$user_settings_name);
     48    register_setting('reading',$setting_prefix . 'lyrics_only');
     49    register_setting('reading',$setting_prefix . 'european');
     50}
     51
     52function cnl_setting_prefix(){
     53    $current_user = wp_get_current_user();
     54    if($current_user->exists()){
     55        return 'cnl_' . $current_user->user_login . '_';
     56    }
     57    return 'cnl_unknown_';
    5158}
    5259
    5360function cnl_setting_section(){
    54     echo '<p>Select options for displaying chords</p>';
     61    $current_user = wp_get_current_user();
     62    $debug_name = $current_user->user_login;
     63   echo '<p>Select options for displaying chords for ' . $debug_name . '</p>';
    5564}
    5665
    5766function cnl_lyrics_only_enabled(){
    58     global $userdata;
    59     wp_get_current_user();
    60     $user_settings_name = 'cnl_setting_values_for_' . $userdata->user_login;
    61     $cnl_options = get_option($user_settings_name);
    62     if($cnl_options['lyrics-only']){
     67    $option_name = cnl_setting_prefix() . 'lyrics_only';
     68    $option = get_option($option_name);
     69    if($option){
    6370        $checked = ' checked="checked" ';
    6471    }
    65     echo '<input '.$checked.' name="'.$user_settings_name.'[lyrics-only]" type="checkbox" />Lyrics Only';
     72    echo '<input '.$checked.' name="'.$option_name.'" type="checkbox" />Lyrics Only';
    6673}
    6774
    6875function cnl_european_chords_enabled(){
    69     global $userdata;
    70     wp_get_current_user();
    71     $user_settings_name = 'cnl_setting_values_for_' . $userdata->user_login;
    72     $cnl_options = get_option($user_settings_name);
    73     if($cnl_options['european-chords']){
     76    $option_name = cnl_setting_prefix() . 'european';
     77    $option = get_option($option_name);
     78    if($option){
    7479        $checked = ' checked="checked" ';
    7580    }
    76     echo '<input '.$checked.' name="'.$user_settings_name.'[european-chords]" type="checkbox" />European chords';
     81    echo '<input '.$checked.' name="'.$option_name.'" type="checkbox" />European chords';
    7782}
    7883
     
    125130{
    126131    private $lyricsOnly;
    127     private $twoPages;
    128132    private $transpose;
    129133    private $size;
     
    133137    public function __construct()
    134138    {
    135         global $userdata;
    136         wp_get_current_user();
    137         $user_settings_name = 'cnl_setting_values_for_' . $userdata->user_login;
    138         $cnl_options = get_option($user_settings_name);
    139         $this->lyricsOnly = $cnl_options['lyrics-only'];
    140         $this->twoPages = $cnl_options['two-pages'];
     139        $this->lyricsOnly = get_option(cnl_setting_prefix().'lyrics_only');
    141140        $this->transpose = 0;
    142         $this->displayEuropean = $cnl_options['european-chords'];
     141        $this->displayEuropean = get_option(cnl_setting_prefix().'european');
    143142    }
    144143
     
    182181        $lineNum = 1;
    183182        foreach( $text as $line ){
    184             if($this->twoPages=='on'){
    185                 //TODO: provide a mechanism to allow the author to split pages
    186             }
    187183            $returnText .= $this->FormatAndDisplayLine($line,$lineNum++);
    188184        }
  • chords-and-lyrics/trunk/readme.txt

    r1859971 r3087130  
    7777== Changelog ==
    7878
     79= 1.8.0 =
     80* Fix deprecated get_currentuserinfo error
     81
    7982= 1.7.0 =
    8083* Add support for European chord style (aHcdefg, B=Bb)
Note: See TracChangeset for help on using the changeset viewer.