Changeset 2956925
- Timestamp:
- 08/22/2023 04:14:46 PM (3 years ago)
- Location:
- chordpress
- Files:
-
- 6 edited
- 23 copied
-
tags/3.4.0/chordpress.php (modified) (1 diff)
-
tags/3.4.1 (copied) (copied from chordpress/trunk)
-
tags/3.4.1/admin/class-chordpress-admin.php (copied) (copied from chordpress/trunk/admin/class-chordpress-admin.php)
-
tags/3.4.1/admin/js/tinymce_buttons.js (copied) (copied from chordpress/trunk/admin/js/tinymce_buttons.js)
-
tags/3.4.1/admin/partials/chordpress-admin-chord-meta-box.php (copied) (copied from chordpress/trunk/admin/partials/chordpress-admin-chord-meta-box.php)
-
tags/3.4.1/admin/partials/chordpress-admin-license.php (copied) (copied from chordpress/trunk/admin/partials/chordpress-admin-license.php)
-
tags/3.4.1/admin/partials/chordpress-admin-options.php (copied) (copied from chordpress/trunk/admin/partials/chordpress-admin-options.php)
-
tags/3.4.1/chordpress.php (copied) (copied from chordpress/trunk/chordpress.php) (2 diffs)
-
tags/3.4.1/includes/class-chordpress-activator.php (copied) (copied from chordpress/trunk/includes/class-chordpress-activator.php)
-
tags/3.4.1/includes/class-chordpress-chord.php (copied) (copied from chordpress/trunk/includes/class-chordpress-chord.php) (51 diffs)
-
tags/3.4.1/includes/class-chordpress-deactivator.php (copied) (copied from chordpress/trunk/includes/class-chordpress-deactivator.php)
-
tags/3.4.1/includes/class-chordpress-i18n.php (copied) (copied from chordpress/trunk/includes/class-chordpress-i18n.php)
-
tags/3.4.1/includes/class-chordpress-license.php (copied) (copied from chordpress/trunk/includes/class-chordpress-license.php)
-
tags/3.4.1/includes/class-chordpress-loader.php (copied) (copied from chordpress/trunk/includes/class-chordpress-loader.php)
-
tags/3.4.1/includes/class-chordpress-plugin.php (copied) (copied from chordpress/trunk/includes/class-chordpress-plugin.php)
-
tags/3.4.1/includes/class-chordpress-renderer.php (copied) (copied from chordpress/trunk/includes/class-chordpress-renderer.php) (2 diffs)
-
tags/3.4.1/languages/chordpress.pot (copied) (copied from chordpress/trunk/languages/chordpress.pot)
-
tags/3.4.1/makepot.cmd (copied) (copied from chordpress/trunk/makepot.cmd)
-
tags/3.4.1/public/class-chordpress-public.php (copied) (copied from chordpress/trunk/public/class-chordpress-public.php) (18 diffs)
-
tags/3.4.1/public/css/chordpress-public.css (copied) (copied from chordpress/trunk/public/css/chordpress-public.css)
-
tags/3.4.1/public/js/chordpress-public.js (copied) (copied from chordpress/trunk/public/js/chordpress-public.js)
-
tags/3.4.1/public/partials/chordpress-public-display.php (copied) (copied from chordpress/trunk/public/partials/chordpress-public-display.php)
-
tags/3.4.1/readme.txt (copied) (copied from chordpress/trunk/readme.txt) (1 diff)
-
tags/3.4.1/uninstall.php (copied) (copied from chordpress/trunk/uninstall.php)
-
trunk/chordpress.php (modified) (2 diffs)
-
trunk/includes/class-chordpress-chord.php (modified) (51 diffs)
-
trunk/includes/class-chordpress-renderer.php (modified) (2 diffs)
-
trunk/public/class-chordpress-public.php (modified) (18 diffs)
-
trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
chordpress/tags/3.4.0/chordpress.php
r2877462 r2956925 17 17 * Plugin URI: https://lewe.gitbook.io/lewe-chordpress/ 18 18 * Description: This plugin renders ChordPro formatted text and chord diagrams in WordPress sites. 19 * Version: 3. 3.319 * Version: 3.4.0 20 20 * Author: George Lewe 21 21 * Author URI: https://www.lewe.com -
chordpress/tags/3.4.1/chordpress.php
r2878621 r2956925 17 17 * Plugin URI: https://lewe.gitbook.io/lewe-chordpress/ 18 18 * Description: This plugin renders ChordPro formatted text and chord diagrams in WordPress sites. 19 * Version: 3.4. 019 * Version: 3.4.1 20 20 * Author: George Lewe 21 21 * Author URI: https://www.lewe.com … … 36 36 */ 37 37 define('CHORDPRESS_NAME', 'ChordPress'); 38 define('CHORDPRESS_VERSION', '3.4. 0');38 define('CHORDPRESS_VERSION', '3.4.1'); 39 39 define('CHORDPRESS_AUTHOR', 'George Lewe'); 40 40 define('CHORDPRESS_AUTHOR_URI', 'https://www.lewe.com'); -
chordpress/tags/3.4.1/includes/class-chordpress-chord.php
r2877462 r2956925 18 18 * @since 3.0.0 19 19 * @access private 20 * @var string $backgroundColorThe 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. 21 21 * To set the background to transparent either set this to 'none' or undefined. Default: 'none' 22 22 */ … … 28 28 * @since 3.0.0 29 29 * @access private 30 * @var integer $barreChordRadiusBarre 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, 31 31 * 0 means not rounded at all). Default: 0.25 32 32 */ … … 38 38 * @since 3.0.0 39 39 * @access private 40 * @var string $barreChordStrokeColorStroke 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' 41 41 */ 42 42 private $barreChordStrokeColor; … … 47 47 * @since 3.0.0 48 48 * @access private 49 * @var integer $barreChordStrokeWidthStroke width of a barre chord. Default: 049 * @var integer $barreChordStrokeWidth Stroke width of a barre chord. Default: 0 50 50 */ 51 51 private $barreChordStrokeWidth; … … 59 59 * @since 3.0.0 60 60 * @access private 61 * @var string $barresJavascript array of [fromString, toString, fret, text, color, textColor]61 * @var string $barres Javascript array of [fromString, toString, fret, text, color, textColor] 62 62 */ 63 63 private $barres; … … 68 68 * @since 3.0.0 69 69 * @access private 70 * @var integer $canvasWidthCanvas width in pixel. The height is automatically adjusted.70 * @var integer $canvasWidth Canvas width in pixel. The height is automatically adjusted. 71 71 */ 72 72 private $canvasWidth; … … 77 77 * @since 3.0.0 78 78 * @access private 79 * @var string $colorGlobal color of the whole chart. Can be overridden with more specifig color settings such as79 * @var string $color Global color of the whole chart. Can be overridden with more specifig color settings such as 80 80 * $titleColor or $stringColor etc. Default: '#000000' 81 81 */ … … 87 87 * @since 3.0.0 88 88 * @access private 89 * @var integer $emptyStringIndicatorSizeSize of the Xs and Os above empty strings relative to the space between two strings. Default: 0.689 * @var integer $emptyStringIndicatorSize Size of the Xs and Os above empty strings relative to the space between two strings. Default: 0.6 90 90 */ 91 91 private $emptyStringIndicatorSize; … … 101 101 * @since 3.0.0 102 102 * @access private 103 * @var string $fingersJavascript array of [string, fret, text | options]103 * @var string $fingers Javascript array of [string, fret, text | options] 104 104 */ 105 105 private $fingers; … … 110 110 * @since 3.0.0 111 111 * @access private 112 * @var string $fixedDiagramPositionWhen 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, 113 113 * no matter if a title is defined or not. Default: 'false' 114 114 */ … … 120 120 * @since 3.0.0 121 121 * @access private 122 * @var string $fontFamilyThe 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' 123 123 */ 124 124 private $fontFamily; … … 129 129 * @since 3.0.0 130 130 * @access private 131 * @var string $fretColorFret color (overrides $color). Default: '#000000'131 * @var string $fretColor Fret color (overrides $color). Default: '#000000' 132 132 */ 133 133 private $fretColor; … … 138 138 * @since 3.0.0 139 139 * @access private 140 * @var string $fretLabelColorFret position color (overrides $color). Default: '#000000'140 * @var string $fretLabelColor Fret position color (overrides $color). Default: '#000000' 141 141 */ 142 142 private $fretLabelColor; … … 147 147 * @since 3.0.0 148 148 * @access private 149 * @var string $fretLabelPositionPosition of the fret label (eg. "3fr"). Default: 'right'149 * @var string $fretLabelPosition Position of the fret label (eg. "3fr"). Default: 'right' 150 150 */ 151 151 private $fretLabelPosition; … … 156 156 * @since 3.0.0 157 157 * @access private 158 * @var integer $fretLabelFontSizeFont size of the fret label. Default: 38158 * @var integer $fretLabelFontSize Font size of the fret label. Default: 38 159 159 */ 160 160 private $fretLabelFontSize; … … 165 165 * @since 3.0.0 166 166 * @access private 167 * @var integer $fretsNumber of frets to show. Default: 4167 * @var integer $frets Number of frets to show. Default: 4 168 168 */ 169 169 private $frets; … … 174 174 * @since 3.0.0 175 175 * @access private 176 * @var integer $fretSizeHeight of a fret, relative to the space between two strings. Default: 1.5176 * @var integer $fretSize Height of a fret, relative to the space between two strings. Default: 1.5 177 177 */ 178 178 private $fretSize; … … 183 183 * @since 3.0.0 184 184 * @access private 185 * @var integer $nutSizeSize of a nut relative to the string spacing. Default: 0.65185 * @var integer $nutSize Size of a nut relative to the string spacing. Default: 0.65 186 186 */ 187 187 private $nutSize; … … 192 192 * @since 3.0.0 193 193 * @access private 194 * @var string $nutColorColor of a finger/nut. Default: '#000000'194 * @var string $nutColor Color of a finger/nut. Default: '#000000' 195 195 */ 196 196 private $nutColor; … … 201 201 * @since 3.0.0 202 202 * @access private 203 * @var string $nutStrokeColorStroke 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' 204 204 */ 205 205 private $nutStrokeColor; … … 210 210 * @since 3.0.0 211 211 * @access private 212 * @var integer $nutStrokeWidthStroke width of a nut. Default: 0212 * @var integer $nutStrokeWidth Stroke width of a nut. Default: 0 213 213 */ 214 214 private $nutStrokeWidth; … … 219 219 * @since 3.0.0 220 220 * @access private 221 * @var string $nutTextColorColor of text inside nuts. Default: '#FFF'221 * @var string $nutTextColor Color of text inside nuts. Default: '#FFF' 222 222 */ 223 223 private $nutTextColor; … … 228 228 * @since 3.0.0 229 229 * @access private 230 * @var integer $nutTextSizeSize of text inside nuts. Default: 22230 * @var integer $nutTextSize Size of text inside nuts. Default: 22 231 231 */ 232 232 private $nutTextSize; … … 237 237 * @since 3.0.0 238 238 * @access private 239 * @var integer $positionDefault position if no positon is provided (first fret is 1). Default: 1239 * @var integer $position Default position if no positon is provided (first fret is 1). Default: 1 240 240 */ 241 241 private $position; … … 246 246 * @since 3.0.0 247 247 * @access private 248 * @var integer $sidePaddingThe 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. 249 249 * This is only applied if it's larger than the letters inside of the padding (eg the starting fret). Default: 0.2 250 250 */ … … 256 256 * @since 3.0.0 257 257 * @access private 258 * @var string $stringColorStrings color (overrides $color). Default: '#000000'258 * @var string $stringColor Strings color (overrides $color). Default: '#000000' 259 259 */ 260 260 private $stringColor; … … 265 265 * @since 3.0.0 266 266 * @access private 267 * @var integer $stringsNumber of strings. Default: 6267 * @var integer $strings Number of strings. Default: 6 268 268 */ 269 269 private $strings; … … 274 274 * @since 3.0.0 275 275 * @access private 276 * @var integer $strokeWidthGlobal stroke width. Default: 2276 * @var integer $strokeWidth Global stroke width. Default: 2 277 277 */ 278 278 private $strokeWidth; … … 283 283 * @since 3.0.0 284 284 * @access private 285 * @var string $styleSelect between 'normal' and 'handdrawn'. Default: 'normal'285 * @var string $style Select between 'normal' and 'handdrawn'. Default: 'normal' 286 286 */ 287 287 private $style; … … 292 292 * @since 3.0.0 293 293 * @access private 294 * @var string $titleChart title. Default: 'F# minor'294 * @var string $title Chart title. Default: 'F# minor' 295 295 */ 296 296 private $title; … … 301 301 * @since 3.0.0 302 302 * @access private 303 * @var integer $titleBottomMarginSpace between the title and the chart. Default: 0303 * @var integer $titleBottomMargin Space between the title and the chart. Default: 0 304 304 */ 305 305 private $titleBottomMargin; … … 310 310 * @since 3.0.0 311 311 * @access private 312 * @var string $titleColorTitle color (overrides color). Default: '#000000'312 * @var string $titleColor Title color (overrides color). Default: '#000000' 313 313 */ 314 314 private $titleColor; … … 319 319 * @since 3.0.0 320 320 * @access private 321 * @var integer $titleFontSizeFont 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, 322 322 * the title is automatically scaled so that it fits. Default: 48 323 323 */ … … 329 329 * @since 3.0.0 330 330 * @access private 331 * @var integer $topFretWidthTop fret width (only used if position is 1). Default: 10331 * @var integer $topFretWidth Top fret width (only used if position is 1). Default: 10 332 332 */ 333 333 private $topFretWidth; … … 338 338 * @since 3.0.0 339 339 * @access private 340 * @var string $tuningLabels 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' ]' 341 341 */ 342 342 private $tuning; … … 347 347 * @since 3.0.0 348 348 * @access private 349 * @var string $tuningsColorTunings color (overrides $color). Default: '#000000'349 * @var string $tuningsColor Tunings color (overrides $color). Default: '#000000' 350 350 */ 351 351 private $tuningsColor; … … 356 356 * @since 3.0.0 357 357 * @access private 358 * @var integer $tuningsFontSizeFont size of the tuning labels. Default: 28358 * @var integer $tuningsFontSize Font size of the tuning labels. Default: 28 359 359 */ 360 360 private $tuningsFontSize; 361 361 362 362 363 364 //-------------------------------------------------------------------------- 363 //-------------------------------------------------------------------------- 364 365 365 /** 366 366 * Initialize the class and set its properties. … … 421 421 422 422 //-------------------------------------------------------------------------- 423 423 424 /** 424 425 * Build the SVGuitar Javascript chord parameters 425 426 * 427 * @return string 426 428 * @since 3.0.0 427 * @return string428 429 */ 429 430 public function buildChordParmeters() … … 432 433 if (!strpos($this->barres, 'fromString')) $this->barres = $this->setBarres($this->barres); 433 434 434 $output = ".chord({435 $output = ".chord({ 435 436 title: '" . $this->title . "', 436 437 fingers: [" . htmlspecialchars_decode($this->fingers, ENT_QUOTES) . "], … … 443 444 444 445 //-------------------------------------------------------------------------- 446 445 447 /** 446 448 * Build the SVGuitar Javascript configure parameters 447 449 * 450 * @return string 448 451 * @since 3.0.0 449 * @return string450 452 */ 451 453 public function buildConfigureParmeters() 452 454 { 453 $output = ".configure({455 $output = ".configure({ 454 456 backgroundColor: '" . $this->backgroundColor . "', 455 457 barreChordRadius: " . $this->barreChordRadius . ", … … 490 492 491 493 //-------------------------------------------------------------------------- 494 492 495 /** 493 496 * Create SVGuitar chord div and script. 494 497 * 498 * @param boolean $floatleft Switch to float left (default: false) 499 * @return string HTML SVGuitar chord div and script. 495 500 * @since 2.1.0 496 * @param boolean $floatleft Switch to float left (default: false)497 * @return string HTML SVGuitar chord div and script.498 501 */ 499 502 public function createSvgChord($floatleft = false) 500 503 { 501 $id = $this->random_string( );504 $id = $this->random_string(true); 502 505 503 506 if ($floatleft) $float = 'float:left;'; 504 507 else $float = ''; 505 508 506 /** 509 /** 507 510 * Build output 508 511 */ … … 524 527 525 528 //-------------------------------------------------------------------------- 529 526 530 /** 527 531 * Create SVGuitar chord Javascript function. 528 532 * 533 * @param string $id Unique ID 534 * @return string SVGuitar Javascript function 529 535 * @since 2.1.0 530 * @param string $id Unique ID531 * @return string SVGuitar Javascript function532 536 */ 533 537 public function createSvgChordFunction($id) … … 545 549 546 550 //-------------------------------------------------------------------------- 551 547 552 /** 548 553 * Get private property. 549 554 * 555 * @return misc 550 556 * @since 3.0.0 551 * @return misc552 557 */ 553 558 public function getProperty($property) … … 557 562 558 563 //-------------------------------------------------------------------------- 564 559 565 /** 560 566 * Set private property. 561 567 * 568 * @param string $property Property name 569 * @param misc $value Value to set the property to 562 570 * @since 2.1.0 563 * @param string $property Property name564 * @param misc $value Value to set the property to565 571 */ 566 572 public function setProperty($property, $value) … … 570 576 571 577 // --------------------------------------------------------------------------- 578 572 579 /** 573 580 * Pretty prints an array. 574 581 * 582 * @param array $a Array to print out pretty 583 * @return string 575 584 * @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 577 597 * @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 *588 598 * @since 2.0.0 589 * @param array $a Array to print out pretty590 * @return string591 599 */ 592 600 public function dnd($a) … … 598 606 /** 599 607 * 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 } 607 620 } 608 621 … … 610 623 * Replace brackets. 611 624 * Replaces round brackets with square brackets. 612 * 613 * @param string $inputString with round bracktes625 * 626 * @param string $input String with round bracktes 614 627 * @return string - String with square brackets 615 628 */ … … 622 635 623 636 //-------------------------------------------------------------------------- 637 624 638 /** 625 639 * Set Barre. … … 629 643 * {fromString:6,toString:1,fret:1} 630 644 * 645 * @param string Simple tuning string 631 646 * @since 3.0.0 632 * @param string Simple tuning string633 647 */ 634 648 public function setBarres($simpleBarre) … … 638 652 } 639 653 $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] . "}"; 641 655 $this->setProperty('barres', $barres); 642 656 } 643 657 644 658 //-------------------------------------------------------------------------- 659 645 660 /** 646 661 * Set Tuning. … … 650 665 * ['E','A','D','G','B','E'] 651 666 * 667 * @param string Simple tuning string 652 668 * @since 3.0.0 653 * @param string Simple tuning string654 669 */ 655 670 public function setTuning($simpleTuning) -
chordpress/tags/3.4.1/includes/class-chordpress-renderer.php
r2877462 r2956925 608 608 * Print header if directives exist 609 609 */ 610 $randId = $this->random_string( );610 $randId = $this->random_string(true); 611 611 if (strlen($this->arrDirectives['title']) && !$this->hideTitle) { 612 612 $cpressID = str_replace(' ', '-', strtolower(trim($this->arrDirectives['title']))) . '-' . $randId; … … 1454 1454 /** 1455 1455 * 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 } 1463 1468 } 1464 1469 -
chordpress/tags/3.4.1/public/class-chordpress-public.php
r2666259 r2956925 29 29 * @since 1.0.0 30 30 * @access private 31 * @var string $plugin_nameThe ID of this plugin.31 * @var string $plugin_name The ID of this plugin. 32 32 */ 33 33 private $plugin_name; … … 38 38 * @since 1.0.0 39 39 * @access private 40 * @var string $versionThe current version of this plugin.40 * @var string $version The current version of this plugin. 41 41 */ 42 42 private $version; … … 45 45 * Initialize the class and set its properties. 46 46 * 47 * @ since 1.0.048 * @param string $plugin_name The name of theplugin.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 50 50 */ 51 51 public function __construct($plugin_name, $version) … … 78 78 /** 79 79 * Shortcode: chordpress. 80 * 80 * 81 81 * Shortcode arguments 82 82 * float= Rendered text div float style: none/left/right. Default: none. … … 85 85 * interactive= Interactive elements on page: yes/no. Default: no. 86 86 * transpose= Positive number of semitones to transpose the chords. Default: 0. 87 * 88 * @param array $attsArray of settings from shortcode89 * @param string $contentContent wrapped in shortcode87 * 88 * @param array $atts Array of settings from shortcode 89 * @param string $content Content wrapped in shortcode 90 90 * @return string Formatted HTML to display on page 91 91 */ … … 117 117 $content = do_shortcode($content); 118 118 119 /** 119 /** 120 120 * If no formatting is requested, get out of here and display the text as is 121 121 */ … … 126 126 */ 127 127 if (!is_null($content)) { 128 /** 128 /** 129 129 * Initiate ChordPress properties 130 130 */ … … 134 134 $CPR->setTranspose($args['transpose']); 135 135 136 /** 136 /** 137 137 * Break content into separate lines 138 138 */ 139 139 $lines = explode("\n", $content); 140 140 141 /** 141 /** 142 142 * Process the directives of the ChordPro text 143 143 */ 144 144 $CPR->getDirectives($lines); 145 145 146 /** 146 /** 147 147 * Process and return the whole thing 148 148 */ … … 155 155 /** 156 156 * Shortcode: chordpress-chord. 157 * 158 * @param array $attsArray of settings from shortcode159 * @param string $contentContent wrapped in shortcode157 * 158 * @param array $atts Array of settings from shortcode 159 * @param string $content Content wrapped in shortcode 160 160 * @return string Formatted HTML to display on page 161 161 */ … … 164 164 $P = new ChordPress_Plugin(); 165 165 $C = new ChordPress_Chord(); 166 $id = $this->random_string( );166 $id = $this->random_string(true); 167 167 $output = ''; 168 168 … … 195 195 * Retrieve chord data from chord post 196 196 */ 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)); 201 201 $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)); 204 204 205 205 /** … … 227 227 * Retrieve chord data from shortcode parameters 228 228 */ 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']); 235 235 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']); 237 237 } 238 238 … … 246 246 /** 247 247 * Create a modal guitar chord dialog. 248 * 249 * @param integer $postidID of the chord post250 * @param string $chordSVGuitar HTML248 * 249 * @param integer $postid ID of the chord post 250 * @param string $chord SVGuitar HTML 251 251 * @return string Modal chord dialog HTML 252 252 */ … … 280 280 /** 281 281 * Find a guitar chord type post by shortname. 282 * 283 * @param string $shortnameShortname of the guitar post to look for.282 * 283 * @param string $shortname Shortname of the guitar post to look for. 284 284 * @return integer Post ID or NULL 285 285 */ … … 287 287 { 288 288 $query_args = array( 289 'posts_per_page' => 1,290 'post_type' => 'guitar_chord',291 'meta_key' => 'guitar_chord_name',292 'meta_value' => $shortname289 'posts_per_page' => 1, 290 'post_type' => 'guitar_chord', 291 'meta_key' => 'guitar_chord_name', 292 'meta_value' => $shortname 293 293 ); 294 294 $query_result = new WP_Query($query_args); … … 299 299 /** 300 300 * Build a guitar chord from post ID. 301 * 302 * @param string $postidPost ID301 * 302 * @param string $postid Post ID 303 303 * @return string SVGuitar HTML 304 304 */ … … 308 308 * Retrieve chord data from chord post 309 309 */ 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)); 314 314 $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)); 317 317 318 318 /** … … 332 332 /** 333 333 * 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 } 341 346 } 342 347 343 348 // --------------------------------------------------------------------------- 349 344 350 /** 345 351 * Pretty prints an array. 346 352 * 353 * @param array $a Array to print out pretty 354 * @return string 347 355 * @since 2.0.0 348 * @param array $a Array to print out pretty349 * @return string350 356 */ 351 357 private function pretty_dump($a) -
chordpress/tags/3.4.1/readme.txt
r2877462 r2956925 130 130 131 131 == Changelog == 132 = 3.4.1 = 133 * 2023-08-22 134 * Fixed randomly missing chords in cord sheet 135 132 136 = 3.4.0 = 133 137 * 2023-03-09 -
chordpress/trunk/chordpress.php
r2878621 r2956925 17 17 * Plugin URI: https://lewe.gitbook.io/lewe-chordpress/ 18 18 * Description: This plugin renders ChordPro formatted text and chord diagrams in WordPress sites. 19 * Version: 3.4. 019 * Version: 3.4.1 20 20 * Author: George Lewe 21 21 * Author URI: https://www.lewe.com … … 36 36 */ 37 37 define('CHORDPRESS_NAME', 'ChordPress'); 38 define('CHORDPRESS_VERSION', '3.4. 0');38 define('CHORDPRESS_VERSION', '3.4.1'); 39 39 define('CHORDPRESS_AUTHOR', 'George Lewe'); 40 40 define('CHORDPRESS_AUTHOR_URI', 'https://www.lewe.com'); -
chordpress/trunk/includes/class-chordpress-chord.php
r2877462 r2956925 18 18 * @since 3.0.0 19 19 * @access private 20 * @var string $backgroundColorThe 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. 21 21 * To set the background to transparent either set this to 'none' or undefined. Default: 'none' 22 22 */ … … 28 28 * @since 3.0.0 29 29 * @access private 30 * @var integer $barreChordRadiusBarre 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, 31 31 * 0 means not rounded at all). Default: 0.25 32 32 */ … … 38 38 * @since 3.0.0 39 39 * @access private 40 * @var string $barreChordStrokeColorStroke 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' 41 41 */ 42 42 private $barreChordStrokeColor; … … 47 47 * @since 3.0.0 48 48 * @access private 49 * @var integer $barreChordStrokeWidthStroke width of a barre chord. Default: 049 * @var integer $barreChordStrokeWidth Stroke width of a barre chord. Default: 0 50 50 */ 51 51 private $barreChordStrokeWidth; … … 59 59 * @since 3.0.0 60 60 * @access private 61 * @var string $barresJavascript array of [fromString, toString, fret, text, color, textColor]61 * @var string $barres Javascript array of [fromString, toString, fret, text, color, textColor] 62 62 */ 63 63 private $barres; … … 68 68 * @since 3.0.0 69 69 * @access private 70 * @var integer $canvasWidthCanvas width in pixel. The height is automatically adjusted.70 * @var integer $canvasWidth Canvas width in pixel. The height is automatically adjusted. 71 71 */ 72 72 private $canvasWidth; … … 77 77 * @since 3.0.0 78 78 * @access private 79 * @var string $colorGlobal color of the whole chart. Can be overridden with more specifig color settings such as79 * @var string $color Global color of the whole chart. Can be overridden with more specifig color settings such as 80 80 * $titleColor or $stringColor etc. Default: '#000000' 81 81 */ … … 87 87 * @since 3.0.0 88 88 * @access private 89 * @var integer $emptyStringIndicatorSizeSize of the Xs and Os above empty strings relative to the space between two strings. Default: 0.689 * @var integer $emptyStringIndicatorSize Size of the Xs and Os above empty strings relative to the space between two strings. Default: 0.6 90 90 */ 91 91 private $emptyStringIndicatorSize; … … 101 101 * @since 3.0.0 102 102 * @access private 103 * @var string $fingersJavascript array of [string, fret, text | options]103 * @var string $fingers Javascript array of [string, fret, text | options] 104 104 */ 105 105 private $fingers; … … 110 110 * @since 3.0.0 111 111 * @access private 112 * @var string $fixedDiagramPositionWhen 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, 113 113 * no matter if a title is defined or not. Default: 'false' 114 114 */ … … 120 120 * @since 3.0.0 121 121 * @access private 122 * @var string $fontFamilyThe 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' 123 123 */ 124 124 private $fontFamily; … … 129 129 * @since 3.0.0 130 130 * @access private 131 * @var string $fretColorFret color (overrides $color). Default: '#000000'131 * @var string $fretColor Fret color (overrides $color). Default: '#000000' 132 132 */ 133 133 private $fretColor; … … 138 138 * @since 3.0.0 139 139 * @access private 140 * @var string $fretLabelColorFret position color (overrides $color). Default: '#000000'140 * @var string $fretLabelColor Fret position color (overrides $color). Default: '#000000' 141 141 */ 142 142 private $fretLabelColor; … … 147 147 * @since 3.0.0 148 148 * @access private 149 * @var string $fretLabelPositionPosition of the fret label (eg. "3fr"). Default: 'right'149 * @var string $fretLabelPosition Position of the fret label (eg. "3fr"). Default: 'right' 150 150 */ 151 151 private $fretLabelPosition; … … 156 156 * @since 3.0.0 157 157 * @access private 158 * @var integer $fretLabelFontSizeFont size of the fret label. Default: 38158 * @var integer $fretLabelFontSize Font size of the fret label. Default: 38 159 159 */ 160 160 private $fretLabelFontSize; … … 165 165 * @since 3.0.0 166 166 * @access private 167 * @var integer $fretsNumber of frets to show. Default: 4167 * @var integer $frets Number of frets to show. Default: 4 168 168 */ 169 169 private $frets; … … 174 174 * @since 3.0.0 175 175 * @access private 176 * @var integer $fretSizeHeight of a fret, relative to the space between two strings. Default: 1.5176 * @var integer $fretSize Height of a fret, relative to the space between two strings. Default: 1.5 177 177 */ 178 178 private $fretSize; … … 183 183 * @since 3.0.0 184 184 * @access private 185 * @var integer $nutSizeSize of a nut relative to the string spacing. Default: 0.65185 * @var integer $nutSize Size of a nut relative to the string spacing. Default: 0.65 186 186 */ 187 187 private $nutSize; … … 192 192 * @since 3.0.0 193 193 * @access private 194 * @var string $nutColorColor of a finger/nut. Default: '#000000'194 * @var string $nutColor Color of a finger/nut. Default: '#000000' 195 195 */ 196 196 private $nutColor; … … 201 201 * @since 3.0.0 202 202 * @access private 203 * @var string $nutStrokeColorStroke 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' 204 204 */ 205 205 private $nutStrokeColor; … … 210 210 * @since 3.0.0 211 211 * @access private 212 * @var integer $nutStrokeWidthStroke width of a nut. Default: 0212 * @var integer $nutStrokeWidth Stroke width of a nut. Default: 0 213 213 */ 214 214 private $nutStrokeWidth; … … 219 219 * @since 3.0.0 220 220 * @access private 221 * @var string $nutTextColorColor of text inside nuts. Default: '#FFF'221 * @var string $nutTextColor Color of text inside nuts. Default: '#FFF' 222 222 */ 223 223 private $nutTextColor; … … 228 228 * @since 3.0.0 229 229 * @access private 230 * @var integer $nutTextSizeSize of text inside nuts. Default: 22230 * @var integer $nutTextSize Size of text inside nuts. Default: 22 231 231 */ 232 232 private $nutTextSize; … … 237 237 * @since 3.0.0 238 238 * @access private 239 * @var integer $positionDefault position if no positon is provided (first fret is 1). Default: 1239 * @var integer $position Default position if no positon is provided (first fret is 1). Default: 1 240 240 */ 241 241 private $position; … … 246 246 * @since 3.0.0 247 247 * @access private 248 * @var integer $sidePaddingThe 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. 249 249 * This is only applied if it's larger than the letters inside of the padding (eg the starting fret). Default: 0.2 250 250 */ … … 256 256 * @since 3.0.0 257 257 * @access private 258 * @var string $stringColorStrings color (overrides $color). Default: '#000000'258 * @var string $stringColor Strings color (overrides $color). Default: '#000000' 259 259 */ 260 260 private $stringColor; … … 265 265 * @since 3.0.0 266 266 * @access private 267 * @var integer $stringsNumber of strings. Default: 6267 * @var integer $strings Number of strings. Default: 6 268 268 */ 269 269 private $strings; … … 274 274 * @since 3.0.0 275 275 * @access private 276 * @var integer $strokeWidthGlobal stroke width. Default: 2276 * @var integer $strokeWidth Global stroke width. Default: 2 277 277 */ 278 278 private $strokeWidth; … … 283 283 * @since 3.0.0 284 284 * @access private 285 * @var string $styleSelect between 'normal' and 'handdrawn'. Default: 'normal'285 * @var string $style Select between 'normal' and 'handdrawn'. Default: 'normal' 286 286 */ 287 287 private $style; … … 292 292 * @since 3.0.0 293 293 * @access private 294 * @var string $titleChart title. Default: 'F# minor'294 * @var string $title Chart title. Default: 'F# minor' 295 295 */ 296 296 private $title; … … 301 301 * @since 3.0.0 302 302 * @access private 303 * @var integer $titleBottomMarginSpace between the title and the chart. Default: 0303 * @var integer $titleBottomMargin Space between the title and the chart. Default: 0 304 304 */ 305 305 private $titleBottomMargin; … … 310 310 * @since 3.0.0 311 311 * @access private 312 * @var string $titleColorTitle color (overrides color). Default: '#000000'312 * @var string $titleColor Title color (overrides color). Default: '#000000' 313 313 */ 314 314 private $titleColor; … … 319 319 * @since 3.0.0 320 320 * @access private 321 * @var integer $titleFontSizeFont 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, 322 322 * the title is automatically scaled so that it fits. Default: 48 323 323 */ … … 329 329 * @since 3.0.0 330 330 * @access private 331 * @var integer $topFretWidthTop fret width (only used if position is 1). Default: 10331 * @var integer $topFretWidth Top fret width (only used if position is 1). Default: 10 332 332 */ 333 333 private $topFretWidth; … … 338 338 * @since 3.0.0 339 339 * @access private 340 * @var string $tuningLabels 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' ]' 341 341 */ 342 342 private $tuning; … … 347 347 * @since 3.0.0 348 348 * @access private 349 * @var string $tuningsColorTunings color (overrides $color). Default: '#000000'349 * @var string $tuningsColor Tunings color (overrides $color). Default: '#000000' 350 350 */ 351 351 private $tuningsColor; … … 356 356 * @since 3.0.0 357 357 * @access private 358 * @var integer $tuningsFontSizeFont size of the tuning labels. Default: 28358 * @var integer $tuningsFontSize Font size of the tuning labels. Default: 28 359 359 */ 360 360 private $tuningsFontSize; 361 361 362 362 363 364 //-------------------------------------------------------------------------- 363 //-------------------------------------------------------------------------- 364 365 365 /** 366 366 * Initialize the class and set its properties. … … 421 421 422 422 //-------------------------------------------------------------------------- 423 423 424 /** 424 425 * Build the SVGuitar Javascript chord parameters 425 426 * 427 * @return string 426 428 * @since 3.0.0 427 * @return string428 429 */ 429 430 public function buildChordParmeters() … … 432 433 if (!strpos($this->barres, 'fromString')) $this->barres = $this->setBarres($this->barres); 433 434 434 $output = ".chord({435 $output = ".chord({ 435 436 title: '" . $this->title . "', 436 437 fingers: [" . htmlspecialchars_decode($this->fingers, ENT_QUOTES) . "], … … 443 444 444 445 //-------------------------------------------------------------------------- 446 445 447 /** 446 448 * Build the SVGuitar Javascript configure parameters 447 449 * 450 * @return string 448 451 * @since 3.0.0 449 * @return string450 452 */ 451 453 public function buildConfigureParmeters() 452 454 { 453 $output = ".configure({455 $output = ".configure({ 454 456 backgroundColor: '" . $this->backgroundColor . "', 455 457 barreChordRadius: " . $this->barreChordRadius . ", … … 490 492 491 493 //-------------------------------------------------------------------------- 494 492 495 /** 493 496 * Create SVGuitar chord div and script. 494 497 * 498 * @param boolean $floatleft Switch to float left (default: false) 499 * @return string HTML SVGuitar chord div and script. 495 500 * @since 2.1.0 496 * @param boolean $floatleft Switch to float left (default: false)497 * @return string HTML SVGuitar chord div and script.498 501 */ 499 502 public function createSvgChord($floatleft = false) 500 503 { 501 $id = $this->random_string( );504 $id = $this->random_string(true); 502 505 503 506 if ($floatleft) $float = 'float:left;'; 504 507 else $float = ''; 505 508 506 /** 509 /** 507 510 * Build output 508 511 */ … … 524 527 525 528 //-------------------------------------------------------------------------- 529 526 530 /** 527 531 * Create SVGuitar chord Javascript function. 528 532 * 533 * @param string $id Unique ID 534 * @return string SVGuitar Javascript function 529 535 * @since 2.1.0 530 * @param string $id Unique ID531 * @return string SVGuitar Javascript function532 536 */ 533 537 public function createSvgChordFunction($id) … … 545 549 546 550 //-------------------------------------------------------------------------- 551 547 552 /** 548 553 * Get private property. 549 554 * 555 * @return misc 550 556 * @since 3.0.0 551 * @return misc552 557 */ 553 558 public function getProperty($property) … … 557 562 558 563 //-------------------------------------------------------------------------- 564 559 565 /** 560 566 * Set private property. 561 567 * 568 * @param string $property Property name 569 * @param misc $value Value to set the property to 562 570 * @since 2.1.0 563 * @param string $property Property name564 * @param misc $value Value to set the property to565 571 */ 566 572 public function setProperty($property, $value) … … 570 576 571 577 // --------------------------------------------------------------------------- 578 572 579 /** 573 580 * Pretty prints an array. 574 581 * 582 * @param array $a Array to print out pretty 583 * @return string 575 584 * @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 577 597 * @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 *588 598 * @since 2.0.0 589 * @param array $a Array to print out pretty590 * @return string591 599 */ 592 600 public function dnd($a) … … 598 606 /** 599 607 * 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 } 607 620 } 608 621 … … 610 623 * Replace brackets. 611 624 * Replaces round brackets with square brackets. 612 * 613 * @param string $inputString with round bracktes625 * 626 * @param string $input String with round bracktes 614 627 * @return string - String with square brackets 615 628 */ … … 622 635 623 636 //-------------------------------------------------------------------------- 637 624 638 /** 625 639 * Set Barre. … … 629 643 * {fromString:6,toString:1,fret:1} 630 644 * 645 * @param string Simple tuning string 631 646 * @since 3.0.0 632 * @param string Simple tuning string633 647 */ 634 648 public function setBarres($simpleBarre) … … 638 652 } 639 653 $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] . "}"; 641 655 $this->setProperty('barres', $barres); 642 656 } 643 657 644 658 //-------------------------------------------------------------------------- 659 645 660 /** 646 661 * Set Tuning. … … 650 665 * ['E','A','D','G','B','E'] 651 666 * 667 * @param string Simple tuning string 652 668 * @since 3.0.0 653 * @param string Simple tuning string654 669 */ 655 670 public function setTuning($simpleTuning) -
chordpress/trunk/includes/class-chordpress-renderer.php
r2877462 r2956925 608 608 * Print header if directives exist 609 609 */ 610 $randId = $this->random_string( );610 $randId = $this->random_string(true); 611 611 if (strlen($this->arrDirectives['title']) && !$this->hideTitle) { 612 612 $cpressID = str_replace(' ', '-', strtolower(trim($this->arrDirectives['title']))) . '-' . $randId; … … 1454 1454 /** 1455 1455 * 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 } 1463 1468 } 1464 1469 -
chordpress/trunk/public/class-chordpress-public.php
r2666259 r2956925 29 29 * @since 1.0.0 30 30 * @access private 31 * @var string $plugin_nameThe ID of this plugin.31 * @var string $plugin_name The ID of this plugin. 32 32 */ 33 33 private $plugin_name; … … 38 38 * @since 1.0.0 39 39 * @access private 40 * @var string $versionThe current version of this plugin.40 * @var string $version The current version of this plugin. 41 41 */ 42 42 private $version; … … 45 45 * Initialize the class and set its properties. 46 46 * 47 * @ since 1.0.048 * @param string $plugin_name The name of theplugin.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 50 50 */ 51 51 public function __construct($plugin_name, $version) … … 78 78 /** 79 79 * Shortcode: chordpress. 80 * 80 * 81 81 * Shortcode arguments 82 82 * float= Rendered text div float style: none/left/right. Default: none. … … 85 85 * interactive= Interactive elements on page: yes/no. Default: no. 86 86 * transpose= Positive number of semitones to transpose the chords. Default: 0. 87 * 88 * @param array $attsArray of settings from shortcode89 * @param string $contentContent wrapped in shortcode87 * 88 * @param array $atts Array of settings from shortcode 89 * @param string $content Content wrapped in shortcode 90 90 * @return string Formatted HTML to display on page 91 91 */ … … 117 117 $content = do_shortcode($content); 118 118 119 /** 119 /** 120 120 * If no formatting is requested, get out of here and display the text as is 121 121 */ … … 126 126 */ 127 127 if (!is_null($content)) { 128 /** 128 /** 129 129 * Initiate ChordPress properties 130 130 */ … … 134 134 $CPR->setTranspose($args['transpose']); 135 135 136 /** 136 /** 137 137 * Break content into separate lines 138 138 */ 139 139 $lines = explode("\n", $content); 140 140 141 /** 141 /** 142 142 * Process the directives of the ChordPro text 143 143 */ 144 144 $CPR->getDirectives($lines); 145 145 146 /** 146 /** 147 147 * Process and return the whole thing 148 148 */ … … 155 155 /** 156 156 * Shortcode: chordpress-chord. 157 * 158 * @param array $attsArray of settings from shortcode159 * @param string $contentContent wrapped in shortcode157 * 158 * @param array $atts Array of settings from shortcode 159 * @param string $content Content wrapped in shortcode 160 160 * @return string Formatted HTML to display on page 161 161 */ … … 164 164 $P = new ChordPress_Plugin(); 165 165 $C = new ChordPress_Chord(); 166 $id = $this->random_string( );166 $id = $this->random_string(true); 167 167 $output = ''; 168 168 … … 195 195 * Retrieve chord data from chord post 196 196 */ 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)); 201 201 $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)); 204 204 205 205 /** … … 227 227 * Retrieve chord data from shortcode parameters 228 228 */ 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']); 235 235 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']); 237 237 } 238 238 … … 246 246 /** 247 247 * Create a modal guitar chord dialog. 248 * 249 * @param integer $postidID of the chord post250 * @param string $chordSVGuitar HTML248 * 249 * @param integer $postid ID of the chord post 250 * @param string $chord SVGuitar HTML 251 251 * @return string Modal chord dialog HTML 252 252 */ … … 280 280 /** 281 281 * Find a guitar chord type post by shortname. 282 * 283 * @param string $shortnameShortname of the guitar post to look for.282 * 283 * @param string $shortname Shortname of the guitar post to look for. 284 284 * @return integer Post ID or NULL 285 285 */ … … 287 287 { 288 288 $query_args = array( 289 'posts_per_page' => 1,290 'post_type' => 'guitar_chord',291 'meta_key' => 'guitar_chord_name',292 'meta_value' => $shortname289 'posts_per_page' => 1, 290 'post_type' => 'guitar_chord', 291 'meta_key' => 'guitar_chord_name', 292 'meta_value' => $shortname 293 293 ); 294 294 $query_result = new WP_Query($query_args); … … 299 299 /** 300 300 * Build a guitar chord from post ID. 301 * 302 * @param string $postidPost ID301 * 302 * @param string $postid Post ID 303 303 * @return string SVGuitar HTML 304 304 */ … … 308 308 * Retrieve chord data from chord post 309 309 */ 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)); 314 314 $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)); 317 317 318 318 /** … … 332 332 /** 333 333 * 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 } 341 346 } 342 347 343 348 // --------------------------------------------------------------------------- 349 344 350 /** 345 351 * Pretty prints an array. 346 352 * 353 * @param array $a Array to print out pretty 354 * @return string 347 355 * @since 2.0.0 348 * @param array $a Array to print out pretty349 * @return string350 356 */ 351 357 private function pretty_dump($a) -
chordpress/trunk/readme.txt
r2877462 r2956925 130 130 131 131 == Changelog == 132 = 3.4.1 = 133 * 2023-08-22 134 * Fixed randomly missing chords in cord sheet 135 132 136 = 3.4.0 = 133 137 * 2023-03-09
Note: See TracChangeset
for help on using the changeset viewer.