Plugin Directory

Changeset 2956925


Ignore:
Timestamp:
08/22/2023 04:14:46 PM (3 years ago)
Author:
glewe
Message:

Tagging version 3.4.1

Location:
chordpress
Files:
6 edited
23 copied

Legend:

Unmodified
Added
Removed
  • chordpress/tags/3.4.0/chordpress.php

    r2877462 r2956925  
    1717 * Plugin URI:        https://lewe.gitbook.io/lewe-chordpress/
    1818 * Description:       This plugin renders ChordPro formatted text and chord diagrams in WordPress sites.
    19  * Version:           3.3.3
     19 * Version:           3.4.0
    2020 * Author:            George Lewe
    2121 * Author URI:        https://www.lewe.com
  • chordpress/tags/3.4.1/chordpress.php

    r2878621 r2956925  
    1717 * Plugin URI:        https://lewe.gitbook.io/lewe-chordpress/
    1818 * Description:       This plugin renders ChordPro formatted text and chord diagrams in WordPress sites.
    19  * Version:           3.4.0
     19 * Version:           3.4.1
    2020 * Author:            George Lewe
    2121 * Author URI:        https://www.lewe.com
     
    3636 */
    3737define('CHORDPRESS_NAME', 'ChordPress');
    38 define('CHORDPRESS_VERSION', '3.4.0');
     38define('CHORDPRESS_VERSION', '3.4.1');
    3939define('CHORDPRESS_AUTHOR', 'George Lewe');
    4040define('CHORDPRESS_AUTHOR_URI', 'https://www.lewe.com');
  • chordpress/tags/3.4.1/includes/class-chordpress-chord.php

    r2877462 r2956925  
    1818     * @since    3.0.0
    1919     * @access   private
    20      * @var      string    $backgroundColor    The background color of the chord diagram. By default the background is transparent.
     20     * @var      string $backgroundColor The background color of the chord diagram. By default the background is transparent.
    2121     *                                         To set the background to transparent either set this to 'none' or undefined. Default: 'none'
    2222     */
     
    2828     * @since    3.0.0
    2929     * @access   private
    30      * @var      integer    $barreChordRadius    Barre chord rectangle border radius relative to the nutSize (eg. 1 means completely round endges,
     30     * @var      integer $barreChordRadius Barre chord rectangle border radius relative to the nutSize (eg. 1 means completely round endges,
    3131     *                                           0 means not rounded at all). Default: 0.25
    3232     */
     
    3838     * @since    3.0.0
    3939     * @access   private
    40      * @var      string    $barreChordStrokeColor    Stroke color of a barre chord. Defaults to the nut color if not set. Default: '#000000'
     40     * @var      string $barreChordStrokeColor Stroke color of a barre chord. Defaults to the nut color if not set. Default: '#000000'
    4141     */
    4242    private $barreChordStrokeColor;
     
    4747     * @since    3.0.0
    4848     * @access   private
    49      * @var      integer    $barreChordStrokeWidth    Stroke width of a barre chord. Default: 0
     49     * @var      integer $barreChordStrokeWidth Stroke width of a barre chord. Default: 0
    5050     */
    5151    private $barreChordStrokeWidth;
     
    5959     * @since    3.0.0
    6060     * @access   private
    61      * @var      string    $barres    Javascript array of [fromString, toString, fret, text, color, textColor]
     61     * @var      string $barres Javascript array of [fromString, toString, fret, text, color, textColor]
    6262     */
    6363    private $barres;
     
    6868     * @since    3.0.0
    6969     * @access   private
    70      * @var      integer   $canvasWidth    Canvas width in pixel. The height is automatically adjusted.
     70     * @var      integer $canvasWidth Canvas width in pixel. The height is automatically adjusted.
    7171     */
    7272    private $canvasWidth;
     
    7777     * @since    3.0.0
    7878     * @access   private
    79      * @var      string    $color    Global color of the whole chart. Can be overridden with more specifig color settings such as
     79     * @var      string $color Global color of the whole chart. Can be overridden with more specifig color settings such as
    8080     *                               $titleColor or $stringColor etc. Default: '#000000'
    8181     */
     
    8787     * @since    3.0.0
    8888     * @access   private
    89      * @var      integer    $emptyStringIndicatorSize    Size of the Xs and Os above empty strings relative to the space between two strings. Default: 0.6
     89     * @var      integer $emptyStringIndicatorSize Size of the Xs and Os above empty strings relative to the space between two strings. Default: 0.6
    9090     */
    9191    private $emptyStringIndicatorSize;
     
    101101     * @since    3.0.0
    102102     * @access   private
    103      * @var      string    $fingers    Javascript array of [string, fret, text | options]
     103     * @var      string $fingers Javascript array of [string, fret, text | options]
    104104     */
    105105    private $fingers;
     
    110110     * @since    3.0.0
    111111     * @access   private
    112      * @var      string    $fixedDiagramPosition    When set to 'true' the distance between the chord diagram and the top of the SVG stayes the same,
     112     * @var      string $fixedDiagramPosition When set to 'true' the distance between the chord diagram and the top of the SVG stayes the same,
    113113     *                                              no matter if a title is defined or not. Default: 'false'
    114114     */
     
    120120     * @since    3.0.0
    121121     * @access   private
    122      * @var      string    $fontFamily    The font family used for all letters and numbers. Default: 'Arial, "Helvetica Neue", Helvetica, sans-serif'
     122     * @var      string $fontFamily The font family used for all letters and numbers. Default: 'Arial, "Helvetica Neue", Helvetica, sans-serif'
    123123     */
    124124    private $fontFamily;
     
    129129     * @since    3.0.0
    130130     * @access   private
    131      * @var      string    $fretColor    Fret color (overrides $color). Default: '#000000'
     131     * @var      string $fretColor Fret color (overrides $color). Default: '#000000'
    132132     */
    133133    private $fretColor;
     
    138138     * @since    3.0.0
    139139     * @access   private
    140      * @var      string    $fretLabelColor    Fret position color (overrides $color). Default: '#000000'
     140     * @var      string $fretLabelColor Fret position color (overrides $color). Default: '#000000'
    141141     */
    142142    private $fretLabelColor;
     
    147147     * @since    3.0.0
    148148     * @access   private
    149      * @var      string    $fretLabelPosition    Position of the fret label (eg. "3fr"). Default: 'right'
     149     * @var      string $fretLabelPosition Position of the fret label (eg. "3fr"). Default: 'right'
    150150     */
    151151    private $fretLabelPosition;
     
    156156     * @since    3.0.0
    157157     * @access   private
    158      * @var      integer    $fretLabelFontSize    Font size of the fret label. Default: 38
     158     * @var      integer $fretLabelFontSize Font size of the fret label. Default: 38
    159159     */
    160160    private $fretLabelFontSize;
     
    165165     * @since    3.0.0
    166166     * @access   private
    167      * @var      integer    $frets    Number of frets to show. Default: 4
     167     * @var      integer $frets Number of frets to show. Default: 4
    168168     */
    169169    private $frets;
     
    174174     * @since    3.0.0
    175175     * @access   private
    176      * @var      integer    $fretSize    Height of a fret, relative to the space between two strings. Default: 1.5
     176     * @var      integer $fretSize Height of a fret, relative to the space between two strings. Default: 1.5
    177177     */
    178178    private $fretSize;
     
    183183     * @since    3.0.0
    184184     * @access   private
    185      * @var      integer    $nutSize    Size of a nut relative to the string spacing. Default: 0.65
     185     * @var      integer $nutSize Size of a nut relative to the string spacing. Default: 0.65
    186186     */
    187187    private $nutSize;
     
    192192     * @since    3.0.0
    193193     * @access   private
    194      * @var      string    $nutColor    Color of a finger/nut. Default: '#000000'
     194     * @var      string $nutColor Color of a finger/nut. Default: '#000000'
    195195     */
    196196    private $nutColor;
     
    201201     * @since    3.0.0
    202202     * @access   private
    203      * @var      string    $nutStrokeColor    Stroke color of a nut. Defaults to the nut color if not set. Default: '#000000'
     203     * @var      string $nutStrokeColor Stroke color of a nut. Defaults to the nut color if not set. Default: '#000000'
    204204     */
    205205    private $nutStrokeColor;
     
    210210     * @since    3.0.0
    211211     * @access   private
    212      * @var      integer    $nutStrokeWidth    Stroke width of a nut. Default: 0
     212     * @var      integer $nutStrokeWidth Stroke width of a nut. Default: 0
    213213     */
    214214    private $nutStrokeWidth;
     
    219219     * @since    3.0.0
    220220     * @access   private
    221      * @var      string    $nutTextColor    Color of text inside nuts. Default: '#FFF'
     221     * @var      string $nutTextColor Color of text inside nuts. Default: '#FFF'
    222222     */
    223223    private $nutTextColor;
     
    228228     * @since    3.0.0
    229229     * @access   private
    230      * @var      integer    $nutTextSize    Size of text inside nuts. Default: 22
     230     * @var      integer $nutTextSize Size of text inside nuts. Default: 22
    231231     */
    232232    private $nutTextSize;
     
    237237     * @since    3.0.0
    238238     * @access   private
    239      * @var      integer    $position    Default position if no positon is provided (first fret is 1). Default: 1
     239     * @var      integer $position Default position if no positon is provided (first fret is 1). Default: 1
    240240     */
    241241    private $position;
     
    246246     * @since    3.0.0
    247247     * @access   private
    248      * @var      integer    $sidePadding    The minimum side padding (from the guitar to the edge of the SVG) relative to the whole width.
     248     * @var      integer $sidePadding The minimum side padding (from the guitar to the edge of the SVG) relative to the whole width.
    249249     *                                      This is only applied if it's larger than the letters inside of the padding (eg the starting fret). Default: 0.2
    250250     */
     
    256256     * @since    3.0.0
    257257     * @access   private
    258      * @var      string    $stringColor    Strings color (overrides $color). Default: '#000000'
     258     * @var      string $stringColor Strings color (overrides $color). Default: '#000000'
    259259     */
    260260    private $stringColor;
     
    265265     * @since    3.0.0
    266266     * @access   private
    267      * @var      integer    $strings    Number of strings. Default: 6
     267     * @var      integer $strings Number of strings. Default: 6
    268268     */
    269269    private $strings;
     
    274274     * @since    3.0.0
    275275     * @access   private
    276      * @var      integer    $strokeWidth    Global stroke width. Default: 2
     276     * @var      integer $strokeWidth Global stroke width. Default: 2
    277277     */
    278278    private $strokeWidth;
     
    283283     * @since    3.0.0
    284284     * @access   private
    285      * @var      string    $style    Select between 'normal' and 'handdrawn'. Default: 'normal'
     285     * @var      string $style Select between 'normal' and 'handdrawn'. Default: 'normal'
    286286     */
    287287    private $style;
     
    292292     * @since    3.0.0
    293293     * @access   private
    294      * @var      string    $title    Chart title. Default: 'F# minor'
     294     * @var      string $title Chart title. Default: 'F# minor'
    295295     */
    296296    private $title;
     
    301301     * @since    3.0.0
    302302     * @access   private
    303      * @var      integer    $titleBottomMargin    Space between the title and the chart. Default: 0
     303     * @var      integer $titleBottomMargin Space between the title and the chart. Default: 0
    304304     */
    305305    private $titleBottomMargin;
     
    310310     * @since    3.0.0
    311311     * @access   private
    312      * @var      string    $titleColor    Title color (overrides color). Default: '#000000'
     312     * @var      string $titleColor Title color (overrides color). Default: '#000000'
    313313     */
    314314    private $titleColor;
     
    319319     * @since    3.0.0
    320320     * @access   private
    321      * @var      integer    $titleFontSize    Font size of the title. This is only the initial font size. If the title doesn't fit,
     321     * @var      integer $titleFontSize Font size of the title. This is only the initial font size. If the title doesn't fit,
    322322     *                                        the title is automatically scaled so that it fits. Default: 48
    323323     */
     
    329329     * @since    3.0.0
    330330     * @access   private
    331      * @var      integer    $topFretWidth    Top fret width (only used if position is 1). Default: 10
     331     * @var      integer $topFretWidth Top fret width (only used if position is 1). Default: 10
    332332     */
    333333    private $topFretWidth;
     
    338338     * @since    3.0.0
    339339     * @access   private
    340      * @var      string    $tuning    Labels under the strings. Can be any string. Default: '[ 'E', 'A', 'D', 'G', 'B', 'E' ]'
     340     * @var      string $tuning Labels under the strings. Can be any string. Default: '[ 'E', 'A', 'D', 'G', 'B', 'E' ]'
    341341     */
    342342    private $tuning;
     
    347347     * @since    3.0.0
    348348     * @access   private
    349      * @var      string    $tuningsColor    Tunings color (overrides $color). Default: '#000000'
     349     * @var      string $tuningsColor Tunings color (overrides $color). Default: '#000000'
    350350     */
    351351    private $tuningsColor;
     
    356356     * @since    3.0.0
    357357     * @access   private
    358      * @var      integer    $tuningsFontSize    Font size of the tuning labels. Default: 28
     358     * @var      integer $tuningsFontSize Font size of the tuning labels. Default: 28
    359359     */
    360360    private $tuningsFontSize;
    361361
    362362
    363 
    364     //--------------------------------------------------------------------------
     363    //--------------------------------------------------------------------------
     364
    365365    /**
    366366     * Initialize the class and set its properties.
     
    421421
    422422    //--------------------------------------------------------------------------
     423
    423424    /**
    424425     * Build the SVGuitar Javascript chord parameters
    425426     *
     427     * @return    string
    426428     * @since     3.0.0
    427      * @return    string
    428429     */
    429430    public function buildChordParmeters()
     
    432433        if (!strpos($this->barres, 'fromString')) $this->barres = $this->setBarres($this->barres);
    433434
    434         $output  = ".chord({
     435        $output = ".chord({
    435436            title: '" . $this->title . "',
    436437            fingers: [" . htmlspecialchars_decode($this->fingers, ENT_QUOTES) . "],
     
    443444
    444445    //--------------------------------------------------------------------------
     446
    445447    /**
    446448     * Build the SVGuitar Javascript configure parameters
    447449     *
     450     * @return    string
    448451     * @since     3.0.0
    449      * @return    string
    450452     */
    451453    public function buildConfigureParmeters()
    452454    {
    453         $output  = ".configure({
     455        $output = ".configure({
    454456            backgroundColor: '" . $this->backgroundColor . "',
    455457            barreChordRadius: " . $this->barreChordRadius . ",
     
    490492
    491493    //--------------------------------------------------------------------------
     494
    492495    /**
    493496     * Create SVGuitar chord div and script.
    494497     *
     498     * @param boolean $floatleft Switch to float left (default: false)
     499     * @return string  HTML SVGuitar chord div and script.
    495500     * @since  2.1.0
    496      * @param  boolean  $floatleft Switch to float left (default: false)
    497      * @return string  HTML SVGuitar chord div and script.
    498501     */
    499502    public function createSvgChord($floatleft = false)
    500503    {
    501         $id = $this->random_string();
     504        $id = $this->random_string(true);
    502505
    503506        if ($floatleft) $float = 'float:left;';
    504507        else $float = '';
    505508
    506         /** 
     509        /**
    507510         * Build output
    508511         */
     
    524527
    525528    //--------------------------------------------------------------------------
     529
    526530    /**
    527531     * Create SVGuitar chord Javascript function.
    528532     *
     533     * @param string $id Unique ID
     534     * @return string  SVGuitar Javascript function
    529535     * @since  2.1.0
    530      * @param  string  $id  Unique ID
    531      * @return string  SVGuitar Javascript function
    532536     */
    533537    public function createSvgChordFunction($id)
     
    545549
    546550    //--------------------------------------------------------------------------
     551
    547552    /**
    548553     * Get private property.
    549554     *
     555     * @return    misc
    550556     * @since     3.0.0
    551      * @return    misc
    552557     */
    553558    public function getProperty($property)
     
    557562
    558563    //--------------------------------------------------------------------------
     564
    559565    /**
    560566     * Set private property.
    561567     *
     568     * @param string $property Property name
     569     * @param misc $value Value to set the property to
    562570     * @since     2.1.0
    563      * @param     string    $property    Property name
    564      * @param     misc      $value       Value to set the property to
    565571     */
    566572    public function setProperty($property, $value)
     
    570576
    571577    // ---------------------------------------------------------------------------
     578
    572579    /**
    573580     * Pretty prints an array.
    574581     *
     582     * @param array $a Array to print out pretty
     583     * @return   string
    575584     * @since    2.0.0
    576      * @param    array    $a    Array to print out pretty
     585     */
     586    public function pretty_dump($a)
     587    {
     588        return highlight_string("<?php\n\$data =\n" . var_export($a, true) . ";\n?>");
     589    }
     590
     591    // ---------------------------------------------------------------------------
     592
     593    /**
     594     * Dump and Die.
     595     *
     596     * @param array $a Array to print out pretty
    577597     * @return   string
    578      */
    579     public function pretty_dump($a)
    580     {
    581         return highlight_string("<?php\n\$data =\n" . var_export($a, true) . ";\n?>");
    582     }
    583 
    584     // ---------------------------------------------------------------------------
    585     /**
    586      * Dump and Die.
    587      *
    588598     * @since    2.0.0
    589      * @param    array    $a    Array to print out pretty
    590      * @return   string
    591599     */
    592600    public function dnd($a)
     
    598606    /**
    599607     * Generate random string.
    600      *
    601      * @param  integer    $length    Length of random string to generate.
    602      * @return string                Random string
    603      */
    604     private function random_string($length = 10)
    605     {
    606         return substr(str_shuffle(str_repeat($x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
     608     *
     609     * @param boolean $alphaonly - Whether to only use alpha charaters
     610     * @param integer $length - Length of random string to generate
     611     * @return false|string
     612     */
     613    private function random_string($alphaonly = false, $length = 10)
     614    {
     615        if ($alphaonly) {
     616            return substr(str_shuffle(str_repeat($x = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
     617        } else {
     618            return substr(str_shuffle(str_repeat($x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
     619        }
    607620    }
    608621
     
    610623     * Replace brackets.
    611624     * Replaces round brackets with square brackets.
    612      * 
    613      * @param  string $input String with round bracktes
     625     *
     626     * @param string $input String with round bracktes
    614627     * @return string - String with square brackets
    615628     */
     
    622635
    623636    //--------------------------------------------------------------------------
     637
    624638    /**
    625639     * Set Barre.
     
    629643     * {fromString:6,toString:1,fret:1}
    630644     *
     645     * @param string   Simple tuning string
    631646     * @since     3.0.0
    632      * @param     string   Simple tuning string
    633647     */
    634648    public function setBarres($simpleBarre)
     
    638652        }
    639653        $barre_array = explode(",", $simpleBarre);
    640         $barres  = "{fromString:" . $barre_array[0] . ",toString:" . $barre_array[1] . ",fret:" . $barre_array[2] . "}";
     654        $barres = "{fromString:" . $barre_array[0] . ",toString:" . $barre_array[1] . ",fret:" . $barre_array[2] . "}";
    641655        $this->setProperty('barres', $barres);
    642656    }
    643657
    644658    //--------------------------------------------------------------------------
     659
    645660    /**
    646661     * Set Tuning.
     
    650665     * ['E','A','D','G','B','E']
    651666     *
     667     * @param string   Simple tuning string
    652668     * @since     3.0.0
    653      * @param     string   Simple tuning string
    654669     */
    655670    public function setTuning($simpleTuning)
  • chordpress/tags/3.4.1/includes/class-chordpress-renderer.php

    r2877462 r2956925  
    608608         * Print header if directives exist
    609609         */
    610         $randId = $this->random_string();
     610        $randId = $this->random_string(true);
    611611        if (strlen($this->arrDirectives['title']) && !$this->hideTitle) {
    612612            $cpressID = str_replace(' ', '-', strtolower(trim($this->arrDirectives['title']))) . '-' . $randId;
     
    14541454    /**
    14551455     * Generate random string.
    1456      *
    1457      * @param  integer    $length    Length of random string to generate.
    1458      * @return string                Random string
    1459      */
    1460     private function random_string($length = 10)
    1461     {
    1462         return substr(str_shuffle(str_repeat($x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
     1456     *
     1457     * @param boolean $alphaonly - Whether to only use alpha charaters
     1458     * @param integer $length - Length of random string to generate
     1459     * @return false|string
     1460     */
     1461    private function random_string($alphaonly = false, $length = 10)
     1462    {
     1463        if ($alphaonly) {
     1464            return substr(str_shuffle(str_repeat($x = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
     1465        } else {
     1466            return substr(str_shuffle(str_repeat($x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
     1467        }
    14631468    }
    14641469
  • chordpress/tags/3.4.1/public/class-chordpress-public.php

    r2666259 r2956925  
    2929     * @since    1.0.0
    3030     * @access   private
    31      * @var      string    $plugin_name    The ID of this plugin.
     31     * @var      string $plugin_name The ID of this plugin.
    3232     */
    3333    private $plugin_name;
     
    3838     * @since    1.0.0
    3939     * @access   private
    40      * @var      string    $version    The current version of this plugin.
     40     * @var      string $version The current version of this plugin.
    4141     */
    4242    private $version;
     
    4545     * Initialize the class and set its properties.
    4646     *
    47      * @since    1.0.0
    48      * @param      string    $plugin_name       The name of the plugin.
    49      * @param      string    $version    The version of this plugin.
     47     * @param string $plugin_name The name of the plugin.
     48     * @param string $version The version of this plugin.
     49     * @since    1.0.0
    5050     */
    5151    public function __construct($plugin_name, $version)
     
    7878    /**
    7979     * Shortcode: chordpress.
    80      * 
     80     *
    8181     * Shortcode arguments
    8282     *   float=          Rendered text div float style: none/left/right. Default: none.
     
    8585     *   interactive=    Interactive elements on page: yes/no. Default: no.
    8686     *   transpose=      Positive number of semitones to transpose the chords. Default: 0.
    87      * 
    88      * @param  array   $atts    Array of settings from shortcode
    89      * @param  string  $content Content wrapped in shortcode
     87     *
     88     * @param array $atts Array of settings from shortcode
     89     * @param string $content Content wrapped in shortcode
    9090     * @return string            Formatted HTML to display on page
    9191     */
     
    117117        $content = do_shortcode($content);
    118118
    119         /** 
     119        /**
    120120         * If no formatting is requested, get out of here and display the text as is
    121121         */
     
    126126         */
    127127        if (!is_null($content)) {
    128             /** 
     128            /**
    129129             * Initiate ChordPress properties
    130130             */
     
    134134            $CPR->setTranspose($args['transpose']);
    135135
    136             /** 
     136            /**
    137137             * Break content into separate lines
    138138             */
    139139            $lines = explode("\n", $content);
    140140
    141             /** 
     141            /**
    142142             * Process the directives of the ChordPro text
    143143             */
    144144            $CPR->getDirectives($lines);
    145145
    146             /** 
     146            /**
    147147             * Process and return the whole thing
    148148             */
     
    155155    /**
    156156     * Shortcode: chordpress-chord.
    157      * 
    158      * @param  array   $atts      Array of settings from shortcode
    159      * @param  string  $content    Content wrapped in shortcode
     157     *
     158     * @param array $atts Array of settings from shortcode
     159     * @param string $content Content wrapped in shortcode
    160160     * @return string              Formatted HTML to display on page
    161161     */
     
    164164        $P = new ChordPress_Plugin();
    165165        $C = new ChordPress_Chord();
    166         $id = $this->random_string();
     166        $id = $this->random_string(true);
    167167        $output = '';
    168168
     
    195195                 * Retrieve chord data from chord post
    196196                 */
    197                 $guitar_chord_barres   = esc_html(get_post_meta($args['chord'], 'guitar_chord_barres', true));
    198                 $guitar_chord_fingers  = esc_html(get_post_meta($args['chord'], 'guitar_chord_fingers', true));
    199                 $guitar_chord_frets    = esc_html(get_post_meta($args['chord'], 'guitar_chord_frets', true));
    200                 $guitar_chord_strings  = esc_html(get_post_meta($args['chord'], 'guitar_chord_strings', true));
     197                $guitar_chord_barres = esc_html(get_post_meta($args['chord'], 'guitar_chord_barres', true));
     198                $guitar_chord_fingers = esc_html(get_post_meta($args['chord'], 'guitar_chord_fingers', true));
     199                $guitar_chord_frets = esc_html(get_post_meta($args['chord'], 'guitar_chord_frets', true));
     200                $guitar_chord_strings = esc_html(get_post_meta($args['chord'], 'guitar_chord_strings', true));
    201201                $guitar_chord_position = esc_html(get_post_meta($args['chord'], 'guitar_chord_position', true));
    202                 $guitar_chord_title    = get_the_title($args['chord']);
    203                 $guitar_chord_tuning   = esc_html(get_post_meta($args['chord'], 'guitar_chord_tuning', true));
     202                $guitar_chord_title = get_the_title($args['chord']);
     203                $guitar_chord_tuning = esc_html(get_post_meta($args['chord'], 'guitar_chord_tuning', true));
    204204
    205205                /**
     
    227227             * Retrieve chord data from shortcode parameters
    228228             */
    229             if (strlen($args['barre']))     $C->setBarres($args['barre']);
    230             if (strlen($args['fingers']))   $C->setProperty('fingers', $C->replace_brackets($args['fingers']));
    231             if (strlen($args['frets']))     $C->setProperty('frets', $args['frets']);
    232             if (strlen($args['position']))  $C->setProperty('position', $args['position']);
    233             if (strlen($args['strings']))   $C->setProperty('strings', $args['strings']);
    234             if (strlen($args['title']))     $C->setProperty('title', $args['title']);
     229            if (strlen($args['barre'])) $C->setBarres($args['barre']);
     230            if (strlen($args['fingers'])) $C->setProperty('fingers', $C->replace_brackets($args['fingers']));
     231            if (strlen($args['frets'])) $C->setProperty('frets', $args['frets']);
     232            if (strlen($args['position'])) $C->setProperty('position', $args['position']);
     233            if (strlen($args['strings'])) $C->setProperty('strings', $args['strings']);
     234            if (strlen($args['title'])) $C->setProperty('title', $args['title']);
    235235            else $C->setProperty('title', __('No Title', 'chordpress'));
    236             if (strlen($args['tuning']))    $C->setTuning($args['tuning']);
     236            if (strlen($args['tuning'])) $C->setTuning($args['tuning']);
    237237        }
    238238
     
    246246    /**
    247247     * Create a modal guitar chord dialog.
    248      * 
    249      * @param  integer    $postid    ID of the chord post
    250      * @param  string     $chord    SVGuitar HTML
     248     *
     249     * @param integer $postid ID of the chord post
     250     * @param string $chord SVGuitar HTML
    251251     * @return string                Modal chord dialog HTML
    252252     */
     
    280280    /**
    281281     * Find a guitar chord type post by shortname.
    282      * 
    283      * @param  string    $shortname    Shortname of the guitar post to look for.
     282     *
     283     * @param string $shortname Shortname of the guitar post to look for.
    284284     * @return integer                 Post ID or NULL
    285285     */
     
    287287    {
    288288        $query_args = array(
    289             'posts_per_page'   => 1,
    290             'post_type'        => 'guitar_chord',
    291             'meta_key'         => 'guitar_chord_name',
    292             'meta_value'       => $shortname
     289            'posts_per_page' => 1,
     290            'post_type' => 'guitar_chord',
     291            'meta_key' => 'guitar_chord_name',
     292            'meta_value' => $shortname
    293293        );
    294294        $query_result = new WP_Query($query_args);
     
    299299    /**
    300300     * Build a guitar chord from post ID.
    301      * 
    302      * @param  string    $postid    Post ID
     301     *
     302     * @param string $postid Post ID
    303303     * @return string               SVGuitar HTML
    304304     */
     
    308308         * Retrieve chord data from chord post
    309309         */
    310         $guitar_chord_barres   = esc_html(get_post_meta($positid, 'guitar_chord_barres', true));
    311         $guitar_chord_fingers  = esc_html(get_post_meta($positid, 'guitar_chord_fingers', true));
    312         $guitar_chord_frets    = esc_html(get_post_meta($positid, 'guitar_chord_frets', true));
    313         $guitar_chord_strings  = esc_html(get_post_meta($positid, 'guitar_chord_strings', true));
     310        $guitar_chord_barres = esc_html(get_post_meta($positid, 'guitar_chord_barres', true));
     311        $guitar_chord_fingers = esc_html(get_post_meta($positid, 'guitar_chord_fingers', true));
     312        $guitar_chord_frets = esc_html(get_post_meta($positid, 'guitar_chord_frets', true));
     313        $guitar_chord_strings = esc_html(get_post_meta($positid, 'guitar_chord_strings', true));
    314314        $guitar_chord_position = esc_html(get_post_meta($positid, 'guitar_chord_position', true));
    315         $guitar_chord_title    = get_the_title($positid);
    316         $guitar_chord_tuning   = esc_html(get_post_meta($positid, 'guitar_chord_tuning', true));
     315        $guitar_chord_title = get_the_title($positid);
     316        $guitar_chord_tuning = esc_html(get_post_meta($positid, 'guitar_chord_tuning', true));
    317317
    318318        /**
     
    332332    /**
    333333     * Generate random string.
    334      *
    335      * @param  integer    $length    Length of random string to generate.
    336      * @return string                Random string
    337      */
    338     private function random_string($length = 10)
    339     {
    340         return substr(str_shuffle(str_repeat($x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
     334     *
     335     * @param boolean $alphaonly - Whether to only use alpha charaters
     336     * @param integer $length - Length of random string to generate.
     337     * @return false|string
     338     */
     339    private function random_string($alphaonly = false, $length = 10)
     340    {
     341        if ($alphaonly) {
     342            return substr(str_shuffle(str_repeat($x = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
     343        } else {
     344            return substr(str_shuffle(str_repeat($x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
     345        }
    341346    }
    342347
    343348    // ---------------------------------------------------------------------------
     349
    344350    /**
    345351     * Pretty prints an array.
    346352     *
     353     * @param array $a Array to print out pretty
     354     * @return   string
    347355     * @since    2.0.0
    348      * @param    array    $a    Array to print out pretty
    349      * @return   string
    350356     */
    351357    private function pretty_dump($a)
  • chordpress/tags/3.4.1/readme.txt

    r2877462 r2956925  
    130130
    131131== Changelog ==
     132= 3.4.1 =
     133* 2023-08-22
     134* Fixed randomly missing chords in cord sheet
     135
    132136= 3.4.0 =
    133137* 2023-03-09
  • chordpress/trunk/chordpress.php

    r2878621 r2956925  
    1717 * Plugin URI:        https://lewe.gitbook.io/lewe-chordpress/
    1818 * Description:       This plugin renders ChordPro formatted text and chord diagrams in WordPress sites.
    19  * Version:           3.4.0
     19 * Version:           3.4.1
    2020 * Author:            George Lewe
    2121 * Author URI:        https://www.lewe.com
     
    3636 */
    3737define('CHORDPRESS_NAME', 'ChordPress');
    38 define('CHORDPRESS_VERSION', '3.4.0');
     38define('CHORDPRESS_VERSION', '3.4.1');
    3939define('CHORDPRESS_AUTHOR', 'George Lewe');
    4040define('CHORDPRESS_AUTHOR_URI', 'https://www.lewe.com');
  • chordpress/trunk/includes/class-chordpress-chord.php

    r2877462 r2956925  
    1818     * @since    3.0.0
    1919     * @access   private
    20      * @var      string    $backgroundColor    The background color of the chord diagram. By default the background is transparent.
     20     * @var      string $backgroundColor The background color of the chord diagram. By default the background is transparent.
    2121     *                                         To set the background to transparent either set this to 'none' or undefined. Default: 'none'
    2222     */
     
    2828     * @since    3.0.0
    2929     * @access   private
    30      * @var      integer    $barreChordRadius    Barre chord rectangle border radius relative to the nutSize (eg. 1 means completely round endges,
     30     * @var      integer $barreChordRadius Barre chord rectangle border radius relative to the nutSize (eg. 1 means completely round endges,
    3131     *                                           0 means not rounded at all). Default: 0.25
    3232     */
     
    3838     * @since    3.0.0
    3939     * @access   private
    40      * @var      string    $barreChordStrokeColor    Stroke color of a barre chord. Defaults to the nut color if not set. Default: '#000000'
     40     * @var      string $barreChordStrokeColor Stroke color of a barre chord. Defaults to the nut color if not set. Default: '#000000'
    4141     */
    4242    private $barreChordStrokeColor;
     
    4747     * @since    3.0.0
    4848     * @access   private
    49      * @var      integer    $barreChordStrokeWidth    Stroke width of a barre chord. Default: 0
     49     * @var      integer $barreChordStrokeWidth Stroke width of a barre chord. Default: 0
    5050     */
    5151    private $barreChordStrokeWidth;
     
    5959     * @since    3.0.0
    6060     * @access   private
    61      * @var      string    $barres    Javascript array of [fromString, toString, fret, text, color, textColor]
     61     * @var      string $barres Javascript array of [fromString, toString, fret, text, color, textColor]
    6262     */
    6363    private $barres;
     
    6868     * @since    3.0.0
    6969     * @access   private
    70      * @var      integer   $canvasWidth    Canvas width in pixel. The height is automatically adjusted.
     70     * @var      integer $canvasWidth Canvas width in pixel. The height is automatically adjusted.
    7171     */
    7272    private $canvasWidth;
     
    7777     * @since    3.0.0
    7878     * @access   private
    79      * @var      string    $color    Global color of the whole chart. Can be overridden with more specifig color settings such as
     79     * @var      string $color Global color of the whole chart. Can be overridden with more specifig color settings such as
    8080     *                               $titleColor or $stringColor etc. Default: '#000000'
    8181     */
     
    8787     * @since    3.0.0
    8888     * @access   private
    89      * @var      integer    $emptyStringIndicatorSize    Size of the Xs and Os above empty strings relative to the space between two strings. Default: 0.6
     89     * @var      integer $emptyStringIndicatorSize Size of the Xs and Os above empty strings relative to the space between two strings. Default: 0.6
    9090     */
    9191    private $emptyStringIndicatorSize;
     
    101101     * @since    3.0.0
    102102     * @access   private
    103      * @var      string    $fingers    Javascript array of [string, fret, text | options]
     103     * @var      string $fingers Javascript array of [string, fret, text | options]
    104104     */
    105105    private $fingers;
     
    110110     * @since    3.0.0
    111111     * @access   private
    112      * @var      string    $fixedDiagramPosition    When set to 'true' the distance between the chord diagram and the top of the SVG stayes the same,
     112     * @var      string $fixedDiagramPosition When set to 'true' the distance between the chord diagram and the top of the SVG stayes the same,
    113113     *                                              no matter if a title is defined or not. Default: 'false'
    114114     */
     
    120120     * @since    3.0.0
    121121     * @access   private
    122      * @var      string    $fontFamily    The font family used for all letters and numbers. Default: 'Arial, "Helvetica Neue", Helvetica, sans-serif'
     122     * @var      string $fontFamily The font family used for all letters and numbers. Default: 'Arial, "Helvetica Neue", Helvetica, sans-serif'
    123123     */
    124124    private $fontFamily;
     
    129129     * @since    3.0.0
    130130     * @access   private
    131      * @var      string    $fretColor    Fret color (overrides $color). Default: '#000000'
     131     * @var      string $fretColor Fret color (overrides $color). Default: '#000000'
    132132     */
    133133    private $fretColor;
     
    138138     * @since    3.0.0
    139139     * @access   private
    140      * @var      string    $fretLabelColor    Fret position color (overrides $color). Default: '#000000'
     140     * @var      string $fretLabelColor Fret position color (overrides $color). Default: '#000000'
    141141     */
    142142    private $fretLabelColor;
     
    147147     * @since    3.0.0
    148148     * @access   private
    149      * @var      string    $fretLabelPosition    Position of the fret label (eg. "3fr"). Default: 'right'
     149     * @var      string $fretLabelPosition Position of the fret label (eg. "3fr"). Default: 'right'
    150150     */
    151151    private $fretLabelPosition;
     
    156156     * @since    3.0.0
    157157     * @access   private
    158      * @var      integer    $fretLabelFontSize    Font size of the fret label. Default: 38
     158     * @var      integer $fretLabelFontSize Font size of the fret label. Default: 38
    159159     */
    160160    private $fretLabelFontSize;
     
    165165     * @since    3.0.0
    166166     * @access   private
    167      * @var      integer    $frets    Number of frets to show. Default: 4
     167     * @var      integer $frets Number of frets to show. Default: 4
    168168     */
    169169    private $frets;
     
    174174     * @since    3.0.0
    175175     * @access   private
    176      * @var      integer    $fretSize    Height of a fret, relative to the space between two strings. Default: 1.5
     176     * @var      integer $fretSize Height of a fret, relative to the space between two strings. Default: 1.5
    177177     */
    178178    private $fretSize;
     
    183183     * @since    3.0.0
    184184     * @access   private
    185      * @var      integer    $nutSize    Size of a nut relative to the string spacing. Default: 0.65
     185     * @var      integer $nutSize Size of a nut relative to the string spacing. Default: 0.65
    186186     */
    187187    private $nutSize;
     
    192192     * @since    3.0.0
    193193     * @access   private
    194      * @var      string    $nutColor    Color of a finger/nut. Default: '#000000'
     194     * @var      string $nutColor Color of a finger/nut. Default: '#000000'
    195195     */
    196196    private $nutColor;
     
    201201     * @since    3.0.0
    202202     * @access   private
    203      * @var      string    $nutStrokeColor    Stroke color of a nut. Defaults to the nut color if not set. Default: '#000000'
     203     * @var      string $nutStrokeColor Stroke color of a nut. Defaults to the nut color if not set. Default: '#000000'
    204204     */
    205205    private $nutStrokeColor;
     
    210210     * @since    3.0.0
    211211     * @access   private
    212      * @var      integer    $nutStrokeWidth    Stroke width of a nut. Default: 0
     212     * @var      integer $nutStrokeWidth Stroke width of a nut. Default: 0
    213213     */
    214214    private $nutStrokeWidth;
     
    219219     * @since    3.0.0
    220220     * @access   private
    221      * @var      string    $nutTextColor    Color of text inside nuts. Default: '#FFF'
     221     * @var      string $nutTextColor Color of text inside nuts. Default: '#FFF'
    222222     */
    223223    private $nutTextColor;
     
    228228     * @since    3.0.0
    229229     * @access   private
    230      * @var      integer    $nutTextSize    Size of text inside nuts. Default: 22
     230     * @var      integer $nutTextSize Size of text inside nuts. Default: 22
    231231     */
    232232    private $nutTextSize;
     
    237237     * @since    3.0.0
    238238     * @access   private
    239      * @var      integer    $position    Default position if no positon is provided (first fret is 1). Default: 1
     239     * @var      integer $position Default position if no positon is provided (first fret is 1). Default: 1
    240240     */
    241241    private $position;
     
    246246     * @since    3.0.0
    247247     * @access   private
    248      * @var      integer    $sidePadding    The minimum side padding (from the guitar to the edge of the SVG) relative to the whole width.
     248     * @var      integer $sidePadding The minimum side padding (from the guitar to the edge of the SVG) relative to the whole width.
    249249     *                                      This is only applied if it's larger than the letters inside of the padding (eg the starting fret). Default: 0.2
    250250     */
     
    256256     * @since    3.0.0
    257257     * @access   private
    258      * @var      string    $stringColor    Strings color (overrides $color). Default: '#000000'
     258     * @var      string $stringColor Strings color (overrides $color). Default: '#000000'
    259259     */
    260260    private $stringColor;
     
    265265     * @since    3.0.0
    266266     * @access   private
    267      * @var      integer    $strings    Number of strings. Default: 6
     267     * @var      integer $strings Number of strings. Default: 6
    268268     */
    269269    private $strings;
     
    274274     * @since    3.0.0
    275275     * @access   private
    276      * @var      integer    $strokeWidth    Global stroke width. Default: 2
     276     * @var      integer $strokeWidth Global stroke width. Default: 2
    277277     */
    278278    private $strokeWidth;
     
    283283     * @since    3.0.0
    284284     * @access   private
    285      * @var      string    $style    Select between 'normal' and 'handdrawn'. Default: 'normal'
     285     * @var      string $style Select between 'normal' and 'handdrawn'. Default: 'normal'
    286286     */
    287287    private $style;
     
    292292     * @since    3.0.0
    293293     * @access   private
    294      * @var      string    $title    Chart title. Default: 'F# minor'
     294     * @var      string $title Chart title. Default: 'F# minor'
    295295     */
    296296    private $title;
     
    301301     * @since    3.0.0
    302302     * @access   private
    303      * @var      integer    $titleBottomMargin    Space between the title and the chart. Default: 0
     303     * @var      integer $titleBottomMargin Space between the title and the chart. Default: 0
    304304     */
    305305    private $titleBottomMargin;
     
    310310     * @since    3.0.0
    311311     * @access   private
    312      * @var      string    $titleColor    Title color (overrides color). Default: '#000000'
     312     * @var      string $titleColor Title color (overrides color). Default: '#000000'
    313313     */
    314314    private $titleColor;
     
    319319     * @since    3.0.0
    320320     * @access   private
    321      * @var      integer    $titleFontSize    Font size of the title. This is only the initial font size. If the title doesn't fit,
     321     * @var      integer $titleFontSize Font size of the title. This is only the initial font size. If the title doesn't fit,
    322322     *                                        the title is automatically scaled so that it fits. Default: 48
    323323     */
     
    329329     * @since    3.0.0
    330330     * @access   private
    331      * @var      integer    $topFretWidth    Top fret width (only used if position is 1). Default: 10
     331     * @var      integer $topFretWidth Top fret width (only used if position is 1). Default: 10
    332332     */
    333333    private $topFretWidth;
     
    338338     * @since    3.0.0
    339339     * @access   private
    340      * @var      string    $tuning    Labels under the strings. Can be any string. Default: '[ 'E', 'A', 'D', 'G', 'B', 'E' ]'
     340     * @var      string $tuning Labels under the strings. Can be any string. Default: '[ 'E', 'A', 'D', 'G', 'B', 'E' ]'
    341341     */
    342342    private $tuning;
     
    347347     * @since    3.0.0
    348348     * @access   private
    349      * @var      string    $tuningsColor    Tunings color (overrides $color). Default: '#000000'
     349     * @var      string $tuningsColor Tunings color (overrides $color). Default: '#000000'
    350350     */
    351351    private $tuningsColor;
     
    356356     * @since    3.0.0
    357357     * @access   private
    358      * @var      integer    $tuningsFontSize    Font size of the tuning labels. Default: 28
     358     * @var      integer $tuningsFontSize Font size of the tuning labels. Default: 28
    359359     */
    360360    private $tuningsFontSize;
    361361
    362362
    363 
    364     //--------------------------------------------------------------------------
     363    //--------------------------------------------------------------------------
     364
    365365    /**
    366366     * Initialize the class and set its properties.
     
    421421
    422422    //--------------------------------------------------------------------------
     423
    423424    /**
    424425     * Build the SVGuitar Javascript chord parameters
    425426     *
     427     * @return    string
    426428     * @since     3.0.0
    427      * @return    string
    428429     */
    429430    public function buildChordParmeters()
     
    432433        if (!strpos($this->barres, 'fromString')) $this->barres = $this->setBarres($this->barres);
    433434
    434         $output  = ".chord({
     435        $output = ".chord({
    435436            title: '" . $this->title . "',
    436437            fingers: [" . htmlspecialchars_decode($this->fingers, ENT_QUOTES) . "],
     
    443444
    444445    //--------------------------------------------------------------------------
     446
    445447    /**
    446448     * Build the SVGuitar Javascript configure parameters
    447449     *
     450     * @return    string
    448451     * @since     3.0.0
    449      * @return    string
    450452     */
    451453    public function buildConfigureParmeters()
    452454    {
    453         $output  = ".configure({
     455        $output = ".configure({
    454456            backgroundColor: '" . $this->backgroundColor . "',
    455457            barreChordRadius: " . $this->barreChordRadius . ",
     
    490492
    491493    //--------------------------------------------------------------------------
     494
    492495    /**
    493496     * Create SVGuitar chord div and script.
    494497     *
     498     * @param boolean $floatleft Switch to float left (default: false)
     499     * @return string  HTML SVGuitar chord div and script.
    495500     * @since  2.1.0
    496      * @param  boolean  $floatleft Switch to float left (default: false)
    497      * @return string  HTML SVGuitar chord div and script.
    498501     */
    499502    public function createSvgChord($floatleft = false)
    500503    {
    501         $id = $this->random_string();
     504        $id = $this->random_string(true);
    502505
    503506        if ($floatleft) $float = 'float:left;';
    504507        else $float = '';
    505508
    506         /** 
     509        /**
    507510         * Build output
    508511         */
     
    524527
    525528    //--------------------------------------------------------------------------
     529
    526530    /**
    527531     * Create SVGuitar chord Javascript function.
    528532     *
     533     * @param string $id Unique ID
     534     * @return string  SVGuitar Javascript function
    529535     * @since  2.1.0
    530      * @param  string  $id  Unique ID
    531      * @return string  SVGuitar Javascript function
    532536     */
    533537    public function createSvgChordFunction($id)
     
    545549
    546550    //--------------------------------------------------------------------------
     551
    547552    /**
    548553     * Get private property.
    549554     *
     555     * @return    misc
    550556     * @since     3.0.0
    551      * @return    misc
    552557     */
    553558    public function getProperty($property)
     
    557562
    558563    //--------------------------------------------------------------------------
     564
    559565    /**
    560566     * Set private property.
    561567     *
     568     * @param string $property Property name
     569     * @param misc $value Value to set the property to
    562570     * @since     2.1.0
    563      * @param     string    $property    Property name
    564      * @param     misc      $value       Value to set the property to
    565571     */
    566572    public function setProperty($property, $value)
     
    570576
    571577    // ---------------------------------------------------------------------------
     578
    572579    /**
    573580     * Pretty prints an array.
    574581     *
     582     * @param array $a Array to print out pretty
     583     * @return   string
    575584     * @since    2.0.0
    576      * @param    array    $a    Array to print out pretty
     585     */
     586    public function pretty_dump($a)
     587    {
     588        return highlight_string("<?php\n\$data =\n" . var_export($a, true) . ";\n?>");
     589    }
     590
     591    // ---------------------------------------------------------------------------
     592
     593    /**
     594     * Dump and Die.
     595     *
     596     * @param array $a Array to print out pretty
    577597     * @return   string
    578      */
    579     public function pretty_dump($a)
    580     {
    581         return highlight_string("<?php\n\$data =\n" . var_export($a, true) . ";\n?>");
    582     }
    583 
    584     // ---------------------------------------------------------------------------
    585     /**
    586      * Dump and Die.
    587      *
    588598     * @since    2.0.0
    589      * @param    array    $a    Array to print out pretty
    590      * @return   string
    591599     */
    592600    public function dnd($a)
     
    598606    /**
    599607     * Generate random string.
    600      *
    601      * @param  integer    $length    Length of random string to generate.
    602      * @return string                Random string
    603      */
    604     private function random_string($length = 10)
    605     {
    606         return substr(str_shuffle(str_repeat($x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
     608     *
     609     * @param boolean $alphaonly - Whether to only use alpha charaters
     610     * @param integer $length - Length of random string to generate
     611     * @return false|string
     612     */
     613    private function random_string($alphaonly = false, $length = 10)
     614    {
     615        if ($alphaonly) {
     616            return substr(str_shuffle(str_repeat($x = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
     617        } else {
     618            return substr(str_shuffle(str_repeat($x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
     619        }
    607620    }
    608621
     
    610623     * Replace brackets.
    611624     * Replaces round brackets with square brackets.
    612      * 
    613      * @param  string $input String with round bracktes
     625     *
     626     * @param string $input String with round bracktes
    614627     * @return string - String with square brackets
    615628     */
     
    622635
    623636    //--------------------------------------------------------------------------
     637
    624638    /**
    625639     * Set Barre.
     
    629643     * {fromString:6,toString:1,fret:1}
    630644     *
     645     * @param string   Simple tuning string
    631646     * @since     3.0.0
    632      * @param     string   Simple tuning string
    633647     */
    634648    public function setBarres($simpleBarre)
     
    638652        }
    639653        $barre_array = explode(",", $simpleBarre);
    640         $barres  = "{fromString:" . $barre_array[0] . ",toString:" . $barre_array[1] . ",fret:" . $barre_array[2] . "}";
     654        $barres = "{fromString:" . $barre_array[0] . ",toString:" . $barre_array[1] . ",fret:" . $barre_array[2] . "}";
    641655        $this->setProperty('barres', $barres);
    642656    }
    643657
    644658    //--------------------------------------------------------------------------
     659
    645660    /**
    646661     * Set Tuning.
     
    650665     * ['E','A','D','G','B','E']
    651666     *
     667     * @param string   Simple tuning string
    652668     * @since     3.0.0
    653      * @param     string   Simple tuning string
    654669     */
    655670    public function setTuning($simpleTuning)
  • chordpress/trunk/includes/class-chordpress-renderer.php

    r2877462 r2956925  
    608608         * Print header if directives exist
    609609         */
    610         $randId = $this->random_string();
     610        $randId = $this->random_string(true);
    611611        if (strlen($this->arrDirectives['title']) && !$this->hideTitle) {
    612612            $cpressID = str_replace(' ', '-', strtolower(trim($this->arrDirectives['title']))) . '-' . $randId;
     
    14541454    /**
    14551455     * Generate random string.
    1456      *
    1457      * @param  integer    $length    Length of random string to generate.
    1458      * @return string                Random string
    1459      */
    1460     private function random_string($length = 10)
    1461     {
    1462         return substr(str_shuffle(str_repeat($x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
     1456     *
     1457     * @param boolean $alphaonly - Whether to only use alpha charaters
     1458     * @param integer $length - Length of random string to generate
     1459     * @return false|string
     1460     */
     1461    private function random_string($alphaonly = false, $length = 10)
     1462    {
     1463        if ($alphaonly) {
     1464            return substr(str_shuffle(str_repeat($x = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
     1465        } else {
     1466            return substr(str_shuffle(str_repeat($x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
     1467        }
    14631468    }
    14641469
  • chordpress/trunk/public/class-chordpress-public.php

    r2666259 r2956925  
    2929     * @since    1.0.0
    3030     * @access   private
    31      * @var      string    $plugin_name    The ID of this plugin.
     31     * @var      string $plugin_name The ID of this plugin.
    3232     */
    3333    private $plugin_name;
     
    3838     * @since    1.0.0
    3939     * @access   private
    40      * @var      string    $version    The current version of this plugin.
     40     * @var      string $version The current version of this plugin.
    4141     */
    4242    private $version;
     
    4545     * Initialize the class and set its properties.
    4646     *
    47      * @since    1.0.0
    48      * @param      string    $plugin_name       The name of the plugin.
    49      * @param      string    $version    The version of this plugin.
     47     * @param string $plugin_name The name of the plugin.
     48     * @param string $version The version of this plugin.
     49     * @since    1.0.0
    5050     */
    5151    public function __construct($plugin_name, $version)
     
    7878    /**
    7979     * Shortcode: chordpress.
    80      * 
     80     *
    8181     * Shortcode arguments
    8282     *   float=          Rendered text div float style: none/left/right. Default: none.
     
    8585     *   interactive=    Interactive elements on page: yes/no. Default: no.
    8686     *   transpose=      Positive number of semitones to transpose the chords. Default: 0.
    87      * 
    88      * @param  array   $atts    Array of settings from shortcode
    89      * @param  string  $content Content wrapped in shortcode
     87     *
     88     * @param array $atts Array of settings from shortcode
     89     * @param string $content Content wrapped in shortcode
    9090     * @return string            Formatted HTML to display on page
    9191     */
     
    117117        $content = do_shortcode($content);
    118118
    119         /** 
     119        /**
    120120         * If no formatting is requested, get out of here and display the text as is
    121121         */
     
    126126         */
    127127        if (!is_null($content)) {
    128             /** 
     128            /**
    129129             * Initiate ChordPress properties
    130130             */
     
    134134            $CPR->setTranspose($args['transpose']);
    135135
    136             /** 
     136            /**
    137137             * Break content into separate lines
    138138             */
    139139            $lines = explode("\n", $content);
    140140
    141             /** 
     141            /**
    142142             * Process the directives of the ChordPro text
    143143             */
    144144            $CPR->getDirectives($lines);
    145145
    146             /** 
     146            /**
    147147             * Process and return the whole thing
    148148             */
     
    155155    /**
    156156     * Shortcode: chordpress-chord.
    157      * 
    158      * @param  array   $atts      Array of settings from shortcode
    159      * @param  string  $content    Content wrapped in shortcode
     157     *
     158     * @param array $atts Array of settings from shortcode
     159     * @param string $content Content wrapped in shortcode
    160160     * @return string              Formatted HTML to display on page
    161161     */
     
    164164        $P = new ChordPress_Plugin();
    165165        $C = new ChordPress_Chord();
    166         $id = $this->random_string();
     166        $id = $this->random_string(true);
    167167        $output = '';
    168168
     
    195195                 * Retrieve chord data from chord post
    196196                 */
    197                 $guitar_chord_barres   = esc_html(get_post_meta($args['chord'], 'guitar_chord_barres', true));
    198                 $guitar_chord_fingers  = esc_html(get_post_meta($args['chord'], 'guitar_chord_fingers', true));
    199                 $guitar_chord_frets    = esc_html(get_post_meta($args['chord'], 'guitar_chord_frets', true));
    200                 $guitar_chord_strings  = esc_html(get_post_meta($args['chord'], 'guitar_chord_strings', true));
     197                $guitar_chord_barres = esc_html(get_post_meta($args['chord'], 'guitar_chord_barres', true));
     198                $guitar_chord_fingers = esc_html(get_post_meta($args['chord'], 'guitar_chord_fingers', true));
     199                $guitar_chord_frets = esc_html(get_post_meta($args['chord'], 'guitar_chord_frets', true));
     200                $guitar_chord_strings = esc_html(get_post_meta($args['chord'], 'guitar_chord_strings', true));
    201201                $guitar_chord_position = esc_html(get_post_meta($args['chord'], 'guitar_chord_position', true));
    202                 $guitar_chord_title    = get_the_title($args['chord']);
    203                 $guitar_chord_tuning   = esc_html(get_post_meta($args['chord'], 'guitar_chord_tuning', true));
     202                $guitar_chord_title = get_the_title($args['chord']);
     203                $guitar_chord_tuning = esc_html(get_post_meta($args['chord'], 'guitar_chord_tuning', true));
    204204
    205205                /**
     
    227227             * Retrieve chord data from shortcode parameters
    228228             */
    229             if (strlen($args['barre']))     $C->setBarres($args['barre']);
    230             if (strlen($args['fingers']))   $C->setProperty('fingers', $C->replace_brackets($args['fingers']));
    231             if (strlen($args['frets']))     $C->setProperty('frets', $args['frets']);
    232             if (strlen($args['position']))  $C->setProperty('position', $args['position']);
    233             if (strlen($args['strings']))   $C->setProperty('strings', $args['strings']);
    234             if (strlen($args['title']))     $C->setProperty('title', $args['title']);
     229            if (strlen($args['barre'])) $C->setBarres($args['barre']);
     230            if (strlen($args['fingers'])) $C->setProperty('fingers', $C->replace_brackets($args['fingers']));
     231            if (strlen($args['frets'])) $C->setProperty('frets', $args['frets']);
     232            if (strlen($args['position'])) $C->setProperty('position', $args['position']);
     233            if (strlen($args['strings'])) $C->setProperty('strings', $args['strings']);
     234            if (strlen($args['title'])) $C->setProperty('title', $args['title']);
    235235            else $C->setProperty('title', __('No Title', 'chordpress'));
    236             if (strlen($args['tuning']))    $C->setTuning($args['tuning']);
     236            if (strlen($args['tuning'])) $C->setTuning($args['tuning']);
    237237        }
    238238
     
    246246    /**
    247247     * Create a modal guitar chord dialog.
    248      * 
    249      * @param  integer    $postid    ID of the chord post
    250      * @param  string     $chord    SVGuitar HTML
     248     *
     249     * @param integer $postid ID of the chord post
     250     * @param string $chord SVGuitar HTML
    251251     * @return string                Modal chord dialog HTML
    252252     */
     
    280280    /**
    281281     * Find a guitar chord type post by shortname.
    282      * 
    283      * @param  string    $shortname    Shortname of the guitar post to look for.
     282     *
     283     * @param string $shortname Shortname of the guitar post to look for.
    284284     * @return integer                 Post ID or NULL
    285285     */
     
    287287    {
    288288        $query_args = array(
    289             'posts_per_page'   => 1,
    290             'post_type'        => 'guitar_chord',
    291             'meta_key'         => 'guitar_chord_name',
    292             'meta_value'       => $shortname
     289            'posts_per_page' => 1,
     290            'post_type' => 'guitar_chord',
     291            'meta_key' => 'guitar_chord_name',
     292            'meta_value' => $shortname
    293293        );
    294294        $query_result = new WP_Query($query_args);
     
    299299    /**
    300300     * Build a guitar chord from post ID.
    301      * 
    302      * @param  string    $postid    Post ID
     301     *
     302     * @param string $postid Post ID
    303303     * @return string               SVGuitar HTML
    304304     */
     
    308308         * Retrieve chord data from chord post
    309309         */
    310         $guitar_chord_barres   = esc_html(get_post_meta($positid, 'guitar_chord_barres', true));
    311         $guitar_chord_fingers  = esc_html(get_post_meta($positid, 'guitar_chord_fingers', true));
    312         $guitar_chord_frets    = esc_html(get_post_meta($positid, 'guitar_chord_frets', true));
    313         $guitar_chord_strings  = esc_html(get_post_meta($positid, 'guitar_chord_strings', true));
     310        $guitar_chord_barres = esc_html(get_post_meta($positid, 'guitar_chord_barres', true));
     311        $guitar_chord_fingers = esc_html(get_post_meta($positid, 'guitar_chord_fingers', true));
     312        $guitar_chord_frets = esc_html(get_post_meta($positid, 'guitar_chord_frets', true));
     313        $guitar_chord_strings = esc_html(get_post_meta($positid, 'guitar_chord_strings', true));
    314314        $guitar_chord_position = esc_html(get_post_meta($positid, 'guitar_chord_position', true));
    315         $guitar_chord_title    = get_the_title($positid);
    316         $guitar_chord_tuning   = esc_html(get_post_meta($positid, 'guitar_chord_tuning', true));
     315        $guitar_chord_title = get_the_title($positid);
     316        $guitar_chord_tuning = esc_html(get_post_meta($positid, 'guitar_chord_tuning', true));
    317317
    318318        /**
     
    332332    /**
    333333     * Generate random string.
    334      *
    335      * @param  integer    $length    Length of random string to generate.
    336      * @return string                Random string
    337      */
    338     private function random_string($length = 10)
    339     {
    340         return substr(str_shuffle(str_repeat($x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
     334     *
     335     * @param boolean $alphaonly - Whether to only use alpha charaters
     336     * @param integer $length - Length of random string to generate.
     337     * @return false|string
     338     */
     339    private function random_string($alphaonly = false, $length = 10)
     340    {
     341        if ($alphaonly) {
     342            return substr(str_shuffle(str_repeat($x = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
     343        } else {
     344            return substr(str_shuffle(str_repeat($x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
     345        }
    341346    }
    342347
    343348    // ---------------------------------------------------------------------------
     349
    344350    /**
    345351     * Pretty prints an array.
    346352     *
     353     * @param array $a Array to print out pretty
     354     * @return   string
    347355     * @since    2.0.0
    348      * @param    array    $a    Array to print out pretty
    349      * @return   string
    350356     */
    351357    private function pretty_dump($a)
  • chordpress/trunk/readme.txt

    r2877462 r2956925  
    130130
    131131== Changelog ==
     132= 3.4.1 =
     133* 2023-08-22
     134* Fixed randomly missing chords in cord sheet
     135
    132136= 3.4.0 =
    133137* 2023-03-09
Note: See TracChangeset for help on using the changeset viewer.