Changeset 3307608
- Timestamp:
- 06/06/2025 05:42:10 PM (10 months ago)
- Location:
- chordpress
- Files:
-
- 5 edited
- 23 copied
-
tags/3.9.3 (copied) (copied from chordpress/trunk)
-
tags/3.9.3/admin/class-chordpress-admin.php (copied) (copied from chordpress/trunk/admin/class-chordpress-admin.php)
-
tags/3.9.3/admin/js/chordpress-admin.js (copied) (copied from chordpress/trunk/admin/js/chordpress-admin.js)
-
tags/3.9.3/admin/js/tinymce_buttons.js (copied) (copied from chordpress/trunk/admin/js/tinymce_buttons.js)
-
tags/3.9.3/admin/partials/chordpress-admin-chord-meta-box.php (copied) (copied from chordpress/trunk/admin/partials/chordpress-admin-chord-meta-box.php)
-
tags/3.9.3/admin/partials/chordpress-admin-license.php (copied) (copied from chordpress/trunk/admin/partials/chordpress-admin-license.php)
-
tags/3.9.3/admin/partials/chordpress-admin-options.php (copied) (copied from chordpress/trunk/admin/partials/chordpress-admin-options.php) (1 diff)
-
tags/3.9.3/chordpress.php (copied) (copied from chordpress/trunk/chordpress.php) (2 diffs)
-
tags/3.9.3/includes/class-chordpress-activator.php (copied) (copied from chordpress/trunk/includes/class-chordpress-activator.php)
-
tags/3.9.3/includes/class-chordpress-chord.php (copied) (copied from chordpress/trunk/includes/class-chordpress-chord.php)
-
tags/3.9.3/includes/class-chordpress-deactivator.php (copied) (copied from chordpress/trunk/includes/class-chordpress-deactivator.php)
-
tags/3.9.3/includes/class-chordpress-i18n.php (copied) (copied from chordpress/trunk/includes/class-chordpress-i18n.php)
-
tags/3.9.3/includes/class-chordpress-license.php (copied) (copied from chordpress/trunk/includes/class-chordpress-license.php)
-
tags/3.9.3/includes/class-chordpress-loader.php (copied) (copied from chordpress/trunk/includes/class-chordpress-loader.php)
-
tags/3.9.3/includes/class-chordpress-plugin.php (copied) (copied from chordpress/trunk/includes/class-chordpress-plugin.php)
-
tags/3.9.3/includes/class-chordpress-renderer.php (copied) (copied from chordpress/trunk/includes/class-chordpress-renderer.php) (62 diffs)
-
tags/3.9.3/languages/chordpress.pot (copied) (copied from chordpress/trunk/languages/chordpress.pot) (4 diffs)
-
tags/3.9.3/makepot.cmd (copied) (copied from chordpress/trunk/makepot.cmd)
-
tags/3.9.3/public/class-chordpress-public.php (copied) (copied from chordpress/trunk/public/class-chordpress-public.php)
-
tags/3.9.3/public/css/chordpress-public.css (copied) (copied from chordpress/trunk/public/css/chordpress-public.css)
-
tags/3.9.3/public/js/chordpress-public.js (copied) (copied from chordpress/trunk/public/js/chordpress-public.js)
-
tags/3.9.3/readme.txt (copied) (copied from chordpress/trunk/readme.txt) (2 diffs)
-
tags/3.9.3/uninstall.php (copied) (copied from chordpress/trunk/uninstall.php)
-
trunk/admin/partials/chordpress-admin-options.php (modified) (1 diff)
-
trunk/chordpress.php (modified) (2 diffs)
-
trunk/includes/class-chordpress-renderer.php (modified) (62 diffs)
-
trunk/languages/chordpress.pot (modified) (4 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
chordpress/tags/3.9.3/admin/partials/chordpress-admin-options.php
r3243398 r3307608 392 392 <td> 393 393 <input type='checkbox' id='<?php echo $pname; ?>_checkbox_fixed_interaction' name='<?php echo $pname; ?>_checkbox_fixed_interaction' <?php checked(get_option($pname . '_checkbox_fixed_interaction'), 1); ?> value='1'> 394 <p class="description"><?php echo esc_html(__('With this option selected, the interaction menu will be fixed at the bottom of the page. Note, that this might lead to unexpected results depending on the WordPress theme you use . You can overwrite this setting per shortcut with "fixedinteraction=yes/no"', 'chordpress')); ?>.</p>394 <p class="description"><?php echo esc_html(__('With this option selected, the interaction menu will be fixed at the bottom of the page. Note, that this might lead to unexpected results depending on the WordPress theme you use and if you use more than one ChordPress songsheet on a page. You can overwrite this setting per shortcut with "fixedinteraction=yes/no"', 'chordpress')); ?>.</p> 395 395 </td> 396 396 </tr> -
chordpress/tags/3.9.3/chordpress.php
r3305993 r3307608 19 19 * Plugin URI: https://lewe.gitbook.io/lewe-chordpress/ 20 20 * Description: This plugin renders ChordPro formatted text and chord diagrams in WordPress sites. 21 * Version: 3.9. 221 * Version: 3.9.3 22 22 * Author: George Lewe 23 23 * Author URI: https://www.lewe.com … … 38 38 */ 39 39 define('CHORDPRESS_NAME', 'ChordPress'); 40 define('CHORDPRESS_VERSION', '3.9. 2');40 define('CHORDPRESS_VERSION', '3.9.3'); 41 41 define('CHORDPRESS_AUTHOR', 'George Lewe'); 42 42 define('CHORDPRESS_AUTHOR_URI', 'https://www.lewe.com'); -
chordpress/tags/3.9.3/includes/class-chordpress-renderer.php
r3305993 r3307608 55 55 * @var array $harmonicaTypes Harmonica types. 56 56 */ 57 private $harmonicaTypes = array( 'tremolo', 'diatonic', 'chromatic' );57 private $harmonicaTypes = [ 'tremolo', 'diatonic', 'chromatic' ]; 58 58 59 59 /** … … 499 499 500 500 private $arrChromaticTranspose = array( 501 '1' => [ '1', '1s', '-1', '-1s', '2', '-2', '-2s', '3', '3s', '-3', '-3s', '-4'],502 '1s' => [ '1s', '-1', '-1s', '2', '-2', '-2s', '3', '3s', '-3', '-3s', '-4', '4' ],503 '-1' => [ '-1', '-1s', '2', '-2', '-2s', '3', '3s', '-3', '-3s', '-4', '4', '4s' ],504 '-1s' => [ '-1s', '2', '-2', '-2s', '3', '3s', '-3', '-3s', '-4', '4', '4s', '-5' ],505 '2' => [ '2', '-2', '-2s', '3', '3s', '-3', '-3s', '-4', '4', '4s', '-5', '-5s' ],506 '-2' => [ '-2', '-2s', '3', '3s', '-3', '-3s', '-4', '4', '4s', '-5', '-5s', '6' ],507 '-2s' => [ '-2s', '3', '3s', '-3', '-3s', '-4', '4', '4s', '-5', '-5s', '6', '-6' ],508 '3' => [ '3', '3s', '-3', '-3s', '-4', '4', '4s', '-5', '-5s', '6', '-6', '-6s' ],509 '3s' => [ '3s', '-3', '-3s', '-4', '4', '4s', '-5', '-5s', '6', '-6', '-6s', '7' ],510 '-3' => [ '-3', '-3s', '-4', '4', '4s', '-5', '-5s', '6', '-6', '-6s', '7', '7s' ],511 '-3s' => [ '-3s', '-4', '4', '4s', '-5', '-5s', '6', '-6', '-6s', '7', '7s', '-7' ],512 '-4' => [ '-4', '4', '4s', '-5', '-5s', '6', '-6', '-6s', '7', '7s', '-7', '-7s' ],513 '4' => [ '4', '4s', '-5', '-5s', '6', '-6', '-6s', '7', '7s', '-7', '-7s', '-8' ],514 '4s' => [ '4s', '-5', '-5s', '6', '-6', '-6s', '7', '7s', '-7', '-7s', '-8', '8' ],515 '-5' => [ '-5', '-5s', '6', '-6', '-6s', '7', '7s', '-7', '-7s', '-8', '8', '9' ],516 '-5s' => [ '-5s', '6', '-6', '-6s', '7', '7s', '-7', '-7s', '-8', '8', '9', '9s' ],517 '6' => [ '6', '-6', '-6s', '7', '7s', '-7', '-7s', '-8', '8', '9', '9s', '-9' ],518 '-6' => [ '-6', '-6s', '7', '7s', '-7', '-7s', '-8', '8', '9', '9s', '-9', '-9s' ],519 '-6s' => [ '-6s', '7', '7s', '-7', '-7s', '-8', '8', '9', '9s', '-9', '-9s', '10' ],520 '7' => [ '7', '7s', '-7', '-7s', '-8', '8', '9', '9s', '-9', '-9s', '10', '-10' ],521 '7s' => [ '7s', '-7', '-7s', '-8', '8', '9', '9s', '-9', '-9s', '10', '-10', '-10s' ],522 '-7' => [ '-7', '-7s', '-8', '8', '9', '9s', '-9', '-9s', '10', '-10', '-10s', '11' ],523 '-7s' => [ '-7s', '-8', '8', '9', '9s', '-9', '-9s', '10', '-10', '-10s', '11', '11s' ],524 '-8' => [ '-8', '8', '9', '9s', '-9', '-9s', '10', '-10', '-10s', '11', '11s', '-11' ],525 '8' => [ '8', '9', '9s', '-9', '-9s', '10', '-10', '-10s', '11', '11s', '-11', '-11s' ],526 '9' => [ '9', '9s', '-9', '-9s', '10', '-10', '-10s', '11', '11s', '-11', '-11s', '-12' ],527 '9s' => [ '9s', '-9', '-9s', '10', '-10', '-10s', '11', '11s', '-11', '-11s', '-12', '12' ],528 '-9' => [ '-9', '-9s', '10', '-10', '-10s', '11', '11s', '-11', '-11s', '-12', '12', '12s' ],529 '-9s' => [ '-9s', '10', '-10', '-10s', '11', '11s', '-11', '-11s', '-12', '12', '12s', ' ' ],530 '10' => [ '10', '-10', '-10s', '11', '11s', '-11', '-11s', '-12', '12', '12s', ' ', ' ' ],531 '-10' => [ '-10', '-10s', '11', '11s', '-11', '-11s', '-12', '12', '12s', ' ', ' ', ' ' ],532 '-10s' => [ '-10s', '11', '11s', '-11', '-11s', '-12', '12', '12s', ' ', ' ', ' ', ' ' ],533 '11' => [ '11', '11s', '-11', '-11s', '-12', '12', '12s', ' ', ' ', ' ', ' ', ' ' ],534 '11s' => [ '11s', '-11', '-11s', '-12', '12', '12s', ' ', ' ', ' ', ' ', ' ', ' ' ],535 '-11' => [ '-11', '-11s', '-12', '12', '12s', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],536 '-11s' => [ '-11s', '-12', '12', '12s', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],537 '-12' => [ '-12', '12', '12s', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],538 '12' => [ '12', '12s', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],539 '12s' => [ '12s', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],501 '1' => [ '1', '1s', '-1', '-1s', '2', '-2', '-2s', '3', '3s', '-3', '-3s', '-4' ], 502 '1s' => [ '1s', '-1', '-1s', '2', '-2', '-2s', '3', '3s', '-3', '-3s', '-4', '4' ], 503 '-1' => [ '-1', '-1s', '2', '-2', '-2s', '3', '3s', '-3', '-3s', '-4', '4', '4s' ], 504 '-1s' => [ '-1s', '2', '-2', '-2s', '3', '3s', '-3', '-3s', '-4', '4', '4s', '-5' ], 505 '2' => [ '2', '-2', '-2s', '3', '3s', '-3', '-3s', '-4', '4', '4s', '-5', '-5s' ], 506 '-2' => [ '-2', '-2s', '3', '3s', '-3', '-3s', '-4', '4', '4s', '-5', '-5s', '6' ], 507 '-2s' => [ '-2s', '3', '3s', '-3', '-3s', '-4', '4', '4s', '-5', '-5s', '6', '-6' ], 508 '3' => [ '3', '3s', '-3', '-3s', '-4', '4', '4s', '-5', '-5s', '6', '-6', '-6s' ], 509 '3s' => [ '3s', '-3', '-3s', '-4', '4', '4s', '-5', '-5s', '6', '-6', '-6s', '7' ], 510 '-3' => [ '-3', '-3s', '-4', '4', '4s', '-5', '-5s', '6', '-6', '-6s', '7', '7s' ], 511 '-3s' => [ '-3s', '-4', '4', '4s', '-5', '-5s', '6', '-6', '-6s', '7', '7s', '-7' ], 512 '-4' => [ '-4', '4', '4s', '-5', '-5s', '6', '-6', '-6s', '7', '7s', '-7', '-7s' ], 513 '4' => [ '4', '4s', '-5', '-5s', '6', '-6', '-6s', '7', '7s', '-7', '-7s', '-8' ], 514 '4s' => [ '4s', '-5', '-5s', '6', '-6', '-6s', '7', '7s', '-7', '-7s', '-8', '8' ], 515 '-5' => [ '-5', '-5s', '6', '-6', '-6s', '7', '7s', '-7', '-7s', '-8', '8', '9' ], 516 '-5s' => [ '-5s', '6', '-6', '-6s', '7', '7s', '-7', '-7s', '-8', '8', '9', '9s' ], 517 '6' => [ '6', '-6', '-6s', '7', '7s', '-7', '-7s', '-8', '8', '9', '9s', '-9' ], 518 '-6' => [ '-6', '-6s', '7', '7s', '-7', '-7s', '-8', '8', '9', '9s', '-9', '-9s' ], 519 '-6s' => [ '-6s', '7', '7s', '-7', '-7s', '-8', '8', '9', '9s', '-9', '-9s', '10' ], 520 '7' => [ '7', '7s', '-7', '-7s', '-8', '8', '9', '9s', '-9', '-9s', '10', '-10' ], 521 '7s' => [ '7s', '-7', '-7s', '-8', '8', '9', '9s', '-9', '-9s', '10', '-10', '-10s' ], 522 '-7' => [ '-7', '-7s', '-8', '8', '9', '9s', '-9', '-9s', '10', '-10', '-10s', '11' ], 523 '-7s' => [ '-7s', '-8', '8', '9', '9s', '-9', '-9s', '10', '-10', '-10s', '11', '11s' ], 524 '-8' => [ '-8', '8', '9', '9s', '-9', '-9s', '10', '-10', '-10s', '11', '11s', '-11' ], 525 '8' => [ '8', '9', '9s', '-9', '-9s', '10', '-10', '-10s', '11', '11s', '-11', '-11s' ], 526 '9' => [ '9', '9s', '-9', '-9s', '10', '-10', '-10s', '11', '11s', '-11', '-11s', '-12' ], 527 '9s' => [ '9s', '-9', '-9s', '10', '-10', '-10s', '11', '11s', '-11', '-11s', '-12', '12' ], 528 '-9' => [ '-9', '-9s', '10', '-10', '-10s', '11', '11s', '-11', '-11s', '-12', '12', '12s' ], 529 '-9s' => [ '-9s', '10', '-10', '-10s', '11', '11s', '-11', '-11s', '-12', '12', '12s', ' ' ], 530 '10' => [ '10', '-10', '-10s', '11', '11s', '-11', '-11s', '-12', '12', '12s', ' ', ' ' ], 531 '-10' => [ '-10', '-10s', '11', '11s', '-11', '-11s', '-12', '12', '12s', ' ', ' ', ' ' ], 532 '-10s' => [ '-10s', '11', '11s', '-11', '-11s', '-12', '12', '12s', ' ', ' ', ' ', ' ' ], 533 '11' => [ '11', '11s', '-11', '-11s', '-12', '12', '12s', ' ', ' ', ' ', ' ', ' ' ], 534 '11s' => [ '11s', '-11', '-11s', '-12', '12', '12s', ' ', ' ', ' ', ' ', ' ', ' ' ], 535 '-11' => [ '-11', '-11s', '-12', '12', '12s', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ], 536 '-11s' => [ '-11s', '-12', '12', '12s', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ], 537 '-12' => [ '-12', '12', '12s', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ], 538 '12' => [ '12', '12s', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ], 539 '12s' => [ '12s', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ], 540 540 ); 541 541 … … 558 558 */ 559 559 private $allowedChordPrefixes = array( '~', '|', '/', '.', '-', '+', '1', '2', '3', '4', '5', '6', '7', '8', '9' ); 560 561 /** 562 * Holds the styles for the songsheet 563 * 564 * @since 3.9.3 565 * @access private 566 * @var string 567 */ 568 private $songsheetStyles = ''; 560 569 561 570 /** … … 616 625 * Get the ChordPro directives and store the supported ones in an array. 617 626 * 618 * @param object $text - Text inside shortcode wrapper.627 * @param array $text - Text inside shortcode wrapper in an array (each line is an array element). 619 628 * 620 629 * @since 1.0.0 621 630 */ 622 public function getDirectives( $text) {631 public function getDirectives(array $text) { 623 632 foreach ($text as $line) { 624 633 $line = trim($this->stripTags($line)); … … 698 707 * </div> 699 708 * 700 * @param object $text - Text inside shortcode wrapper.709 * @param array $text - Text inside shortcode wrapper in an array (each line is an array element). 701 710 * 702 711 * @return string - Formatted HTML of the ChordPro text. 703 712 * @since 1.0.0 704 713 */ 705 public function displayText( $text): string {706 /** 707 * Start of ChordPress wrapper708 */ 709 $ cpressStyles = "<style>div.cpress { float: " . $this->float . "; } div.cpress_line { " . $this->lineStyle . "; } div.cpress_line_section { display: inline; float: left; } div.cpress_line_section .chord .chordshort { " . $this->chordStyle . "; } div.cpress_line_section .lyric { " . $this->lyricsStyle . "; } div.cpress_chorus { " . $this->chorusStyle . "; } div.cpress_verse { " . $this->verseStyle . "; } div.cpress_clear { clear: both; } div.cpress_meta { " . $this->metaStyle . "; } div.cpress_interaction { float: right; } div.cpress_interaction select { width: auto; } span.cpress_comment { " . $this->commentStyle . "; } div.cpress_chordsheet { text-align: center; }</style>";710 711 $ returnText= "\n\n714 public function displayText(array $text): string { 715 /** 716 * The styles need to be a one-line string in a separate variable because it is passed to the Javascript print function 717 */ 718 $this->songsheetStyles = "<style>div.cpress { float: " . $this->float . "; } div.cpress_line { " . $this->lineStyle . "; } div.cpress_line_section { display: inline; float: left; } div.cpress_line_section .chord .chordshort { " . $this->chordStyle . "; } div.cpress_line_section .lyric { " . $this->lyricsStyle . "; } div.cpress_chorus { " . $this->chorusStyle . "; } div.cpress_verse { " . $this->verseStyle . "; } div.cpress_clear { clear: both; } div.cpress_meta { " . $this->metaStyle . "; } div.cpress_interaction { float: right; } div.cpress_interaction select { width: auto; } span.cpress_comment { " . $this->commentStyle . "; } div.cpress_chordsheet { text-align: center; }</style>"; 719 720 $songsheetHtml = "\n\n 712 721 <!--begin: ChordPress SongSheet --> 713 722 <div> 714 " . $ cpressStyles . "723 " . $this->songsheetStyles . " 715 724 </div>\n"; 716 725 … … 719 728 */ 720 729 if (in_array(strtolower($this->interactive), array( "yes", "1", "true" ))) { 721 $interactionForm = "<div class=\"cpress-interaction cpress-row"; 722 if ($this->fixedInteraction) { 723 $interactionForm .= " fixed"; 730 $songsheetHtml .= $this->buildInteractionMenu(); 731 } 732 733 $songsheetHtml .= "<div id=\"%cpressID%\" class=\"cpress\">\n"; 734 735 /** 736 * Print header and subtitle if directives exist 737 */ 738 $randId = $this->random_string(true); 739 if (strlen($this->arrDirectives['title']) && !$this->hideTitle) { 740 $cpressID = str_replace(' ', '-', strtolower(trim($this->arrDirectives['title']))) . '-' . $randId; 741 $songsheetHtml = str_replace('%cpressID%', $cpressID, $songsheetHtml); 742 $songsheetHtml .= '<' . $this->titleLevel . '>' . $this->arrDirectives['title'] . '</' . $this->titleLevel . ">\n"; 743 } else { 744 $cpressID = 'ccpress-id-' . $randId; 745 $songsheetHtml = str_replace('%cpressID%', $cpressID, $songsheetHtml); 746 } 747 if (strlen($this->arrDirectives['subtitle']) && !$this->hideSubtitle) { 748 $songsheetHtml .= '<' . $this->subtitleLevel . '>' . $this->arrDirectives['subtitle'] . '</' . $this->subtitleLevel . ">\n"; 749 } 750 751 /** 752 * Print meta data if directives exist 753 */ 754 if ( 755 strlen($this->arrDirectives['album']) || 756 strlen($this->arrDirectives['artist']) || 757 strlen($this->arrDirectives['capo']) || 758 strlen($this->arrDirectives['composer']) || 759 strlen($this->arrDirectives['key']) || 760 strlen($this->arrDirectives['tempo']) || 761 strlen($this->arrDirectives['time']) || 762 strlen($this->arrDirectives['year']) 763 ) { 764 $songsheetHtml .= "<div class=\"cpress_meta\">\n"; 765 if (strlen($this->arrDirectives['composer']) && !$this->hideComposer) $songsheetHtml .= esc_html(__('Composer', 'chordpress')) . ': ' . $this->arrDirectives['composer'] . "<br>\n"; 766 if (strlen($this->arrDirectives['artist']) && !$this->hideArtist) $songsheetHtml .= esc_html(__('Artist', 'chordpress')) . ': ' . $this->arrDirectives['artist'] . "<br>\n"; 767 if (strlen($this->arrDirectives['year']) && !$this->hideYear) $songsheetHtml .= esc_html(__('Year', 'chordpress')) . ': ' . $this->arrDirectives['year'] . "<br>\n"; 768 if (strlen($this->arrDirectives['album']) && !$this->hideAlbum) $songsheetHtml .= esc_html(__('Album', 'chordpress')) . ': ' . $this->arrDirectives['album'] . "<br>\n"; 769 770 if (strlen($this->arrDirectives['key']) && !$this->hideKey) { 771 $songsheetHtml .= esc_html(__('Key (original)', 'chordpress')) . ': ' . $this->arrDirectives['key'] . "<br>\n"; 772 $songsheetHtml .= esc_html(__('Key (transposed)', 'chordpress')) . ': <span class="chord-hidable-%cpressID% key-%cpressID%-0">' . $this->arrDirectives['key'] . '</span>'; 773 for ($t = 1; $t <= 11; $t++) { 774 $songsheetHtml .= '<span class="chord-hidable-%cpressID% key-%cpressID%-' . $t . '" style="display:none">' . $this->arrTransposeValues[$this->arrDirectives['key']][$t] . '</span>'; 775 } 776 $songsheetHtml .= "<br>\n"; 724 777 } 725 $interactionForm .= "\">"; 726 727 if (!$this->hideFontsize) { 728 $interactionForm .= "<div class='cpress-col cpress-pl-0'>" . __('Font', 'chordpress') . "<br> 778 779 if (strlen($this->arrDirectives['time'])) $songsheetHtml .= esc_html(__('Time', 'chordpress')) . ': ' . $this->arrDirectives['time'] . "<br>\n"; 780 if (strlen($this->arrDirectives['tempo'])) $songsheetHtml .= esc_html(__('Tempo', 'chordpress')) . ': ' . $this->arrDirectives['tempo'] . "<br>\n"; 781 if (strlen($this->arrDirectives['capo'])) $songsheetHtml .= esc_html(__('Capo', 'chordpress')) . ': ' . $this->arrDirectives['capo'] . "<br>\n"; 782 $songsheetHtml = preg_replace('/<br>$/', '', $songsheetHtml); // Remove last <br> 783 $songsheetHtml .= "</div>\n"; 784 } 785 786 /** 787 * Go through each line and process it 788 */ 789 $this->inMonospace = false; 790 foreach ($text as $line) { 791 if ($this->inMonospace && strpos($line, "{end_of_monospace}") === false) { 792 $songsheetHtml .= $line; 793 } else { 794 $songsheetHtml .= $this->formatAndDisplayLine($line); 795 } 796 } 797 $songsheetHtml = str_replace('%cpressID%', $cpressID, $songsheetHtml); 798 799 /** 800 * End of ChordPress song 801 */ 802 $songsheetHtml .= "</div>\n<!--end: ChordPress SongSheet-->\n"; 803 804 /** 805 * Build chord sheet if option set to true. 806 */ 807 if ($this->showChordSheet) { 808 $chordSheetText = "\n<!--begin: ChordPress ChordSheet-->\n"; 809 $chordSheetText .= "<div class='cpress_chordsheet'>\n"; 810 $chordSheetText .= "<div><hr></div>\n"; 811 $chordSheetText .= "<p><i>" . esc_html(__('These known chords are used in this song', 'chordpress')) . ".</i></p>"; 812 $this->uniqueChords = array_unique($this->allChords); 813 foreach ($this->uniqueChords as $uc) { 814 if ($postid = $this->find_guitar_chord_post($uc)) { 815 $this->load_guitar_chord($postid); 816 $chordSheetText .= $this->C->createSvgChord(true); 817 } 818 } 819 $chordSheetText .= "</div>\n<div style=\"clear:both; padding: 16px 0 16px 0;\"><hr></div>\n<!--end: ChordPress ChordSheet-->\n\n"; 820 if ($this->showChordSheetOnTop) { 821 $songsheetHtml = $chordSheetText . $songsheetHtml; 822 } else { 823 $songsheetHtml = $songsheetHtml . $chordSheetText; 824 } 825 } 826 827 // $this->C->dnd($songsheetHtml); 828 return $songsheetHtml . "\n\n"; 829 } 830 831 /** 832 * -------------------------------------------------------------------------- 833 * Builds the Interactive Menu 834 * -------------------------------------------------------------------------- 835 * 836 * Builds the interaction menu for the ChordPress song sheet. 837 * 838 * This function generates the HTML for the interaction menu, which includes 839 * options for font size adjustment, transposition, and printing. The menu 840 * can be fixed at the bottom of the page if the `fixedInteraction` property 841 * is set. The function also handles harmonica-specific options if applicable. 842 * 843 * @return string The HTML string for the interaction menu. 844 * @since 3.9.2 845 * @access private 846 * 847 */ 848 private function buildInteractionMenu(): string { 849 $interactionForm = "<div class=\"cpress-interaction cpress-row"; 850 if ($this->fixedInteraction) { 851 $interactionForm .= " fixed"; 852 } 853 $interactionForm .= "\">"; 854 855 if (!$this->hideFontsize) { 856 $interactionForm .= "<div class='cpress-col cpress-mb-2'>" . __('Font Size', 'chordpress') . "<br> 729 857 <div class='cpress-btn-group' role='group'> 730 858 <button type='button' class='cpress-btn cpress-btn-secondary cpress-btn-sm' onclick=\"changeFontSize('%cpressID%', -5);\">-</button> … … 733 861 </div> 734 862 </div>"; 735 } 736 737 if (!$this->hideTranspose) { 738 $interactionForm .= "<div class='cpress-col' style='display: inline-block;'>"; 739 740 if (!$this->harmonica) { 863 } 864 865 if (!$this->hideTranspose) { 866 $interactionForm .= "<div class='cpress-col' style='display: inline-block;'>"; 867 868 if (!$this->harmonica) { 869 // 870 // Guitar chords 871 // 872 if ($this->showNumericTranspose && !$this->harmonica) { 741 873 // 742 // Guitar chords874 // Let's see if a 'Key' directive was given. If so, we can add the transposed keys to the list. 743 875 // 744 if ($this->showNumericTranspose && !$this->harmonica) { 745 // 746 // Let's see if a 'Key' directive was given. If so, we can add the transposed keys to the list. 747 // 748 if (strlen($this->arrDirectives['key']) && in_array($this->arrDirectives['key'], $this->arrKeys)) { 749 $songKey = "'" . $this->arrDirectives['key'] . "'"; 750 $initialText = '0 (' . $this->arrDirectives['key'] . ')'; 751 } else { 752 $songKey = "''"; 753 $initialText = '0'; 754 } 755 $interactionForm .= __('Transpose', 'chordpress') . "<br> 876 if (strlen($this->arrDirectives['key']) && in_array($this->arrDirectives['key'], $this->arrKeys)) { 877 $songKey = "'" . $this->arrDirectives['key'] . "'"; 878 $initialText = '0 (' . $this->arrDirectives['key'] . ')'; 879 } else { 880 $songKey = "''"; 881 $initialText = '0'; 882 } 883 $interactionForm .= __('Transpose', 'chordpress') . "<br> 756 884 <div class='cpress-btn-group' role='group'> 757 885 <button type='button' class='cpress-btn cpress-btn-secondary cpress-btn-sm' onclick=\"transposeChords('%cpressID%', 'btnTranspose-', 'down', " . $songKey . ");\">-</button> … … 759 887 <button type='button' class='cpress-btn cpress-btn-secondary cpress-btn-sm' onclick=\"transposeChords('%cpressID%', 'btnTranspose-', 'up', " . $songKey . ");\">+</button> 760 888 </div>"; 889 } else { 890 // 891 // Let's see if a 'Key' directive was given. If so, we can add the transposed keys to the list. 892 // 893 if (strlen($this->arrDirectives['key']) && in_array($this->arrDirectives['key'], $this->arrKeys)) { 894 $i = 0; 895 foreach ($this->arrTransposeValues[$this->arrDirectives['key']] as $val) { 896 $tvalues[] = (string)$i . ' => ' . $val; 897 $i++; 898 } 761 899 } else { 762 // 763 // Let's see if a 'Key' directive was given. If so, we can add the transposed keys to the list. 764 // 765 if (strlen($this->arrDirectives['key']) && in_array($this->arrDirectives['key'], $this->arrKeys)) { 766 $i = 0; 767 foreach ($this->arrTransposeValues[$this->arrDirectives['key']] as $val) { 768 $tvalues[] = (string)$i . ' => ' . $val; 769 $i++; 770 } 771 } else { 772 $tvalues = array( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11' ); 773 } 774 $interactionForm .= __('Transpose', 'chordpress') . " 900 $tvalues = array( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11' ); 901 } 902 $interactionForm .= __('Transpose', 'chordpress') . " 775 903 <div class=\"float-right\"> 776 904 <select class=\"cpress-form-control cpress-form-control-sm cpress-py-0 cpress-px-2\" id=\"selTranspose-%cpressID%\" onchange=\"transposeChords('%cpressID%', 'selTranspose-');return false;\" title=\"" . __('Only works for international key names', 'chordpress') . ".\"> … … 789 917 </select> 790 918 </div>"; 791 }792 } else {793 //794 // Harmonica notes795 //796 switch ($this->harmonica) {797 case 'tremolo':798 $selectedDiatonic = '';799 $selectedChromatic = '';800 $selectedTremolo = ' selected';801 break;802 case 'diatonic':803 $selectedDiatonic = ' selected';804 $selectedChromatic = '';805 $selectedTremolo = '';806 break;807 case 'chromatic':808 $selectedDiatonic = '';809 $selectedChromatic = ' selected';810 $selectedTremolo = '';811 break;812 default:813 $selectedDiatonic = '';814 $selectedChromatic = '';815 $selectedTremolo = '';816 break;817 }818 819 $interactionForm .=820 "<div class='cpress-row'>919 } 920 } else { 921 // 922 // Harmonica notes 923 // 924 switch ($this->harmonica) { 925 case 'tremolo': 926 $selectedDiatonic = ''; 927 $selectedChromatic = ''; 928 $selectedTremolo = ' selected'; 929 break; 930 case 'diatonic': 931 $selectedDiatonic = ' selected'; 932 $selectedChromatic = ''; 933 $selectedTremolo = ''; 934 break; 935 case 'chromatic': 936 $selectedDiatonic = ''; 937 $selectedChromatic = ' selected'; 938 $selectedTremolo = ''; 939 break; 940 default: 941 $selectedDiatonic = ''; 942 $selectedChromatic = ''; 943 $selectedTremolo = ''; 944 break; 945 } 946 947 $interactionForm .= 948 "<div class='cpress-row'> 821 949 <div class='cpress-col'>"; 822 950 823 $interactionForm .= __('Harmonica', 'chordpress') . "<br>951 $interactionForm .= __('Harmonica', 'chordpress') . "<br> 824 952 <select 825 953 class=\"cpress-form-control cpress-form-control-sm cpress-py-0 cpress-px-2\" … … 834 962 </select>"; 835 963 836 $interactionForm .= "964 $interactionForm .= " 837 965 </div> 838 966 <div class='cpress-col'>"; 839 967 840 if ($this->harmonica == 'chromatic') {841 $baseNote = "''";842 $initialText = '0';843 $interactionForm .= "<span id='btnTranspose-chromatic'>" . __('Transpose', 'chordpress') . "<br>968 if ($this->harmonica == 'chromatic') { 969 $baseNote = "''"; 970 $initialText = '0'; 971 $interactionForm .= "<span id='btnTranspose-chromatic'>" . __('Transpose', 'chordpress') . "<br> 844 972 <div class='cpress-btn-group' role='group'> 845 973 <button type='button' class='cpress-btn cpress-btn-secondary cpress-btn-sm' onclick=\"transposeChromatic('%cpressID%', 'btnTranspose-', 'down', " . $baseNote . ");\">-</button> … … 848 976 </div> 849 977 </span>"; 850 }851 $interactionForm .= "978 } 979 $interactionForm .= " 852 980 </div> 853 981 </div>"; 854 }855 $interactionForm .= "</div>";856 }857 $interactionForm .= "<div class='cpress-col cpress-pr-0'>";858 if (!$this->hidePrint) {859 $printTitle = 'ChordPress SongSheet';860 if (strlen($this->arrDirectives['title']) && !$this->hideTitle) {861 $printTitle = $this->arrDirectives['title'];862 }863 $interactionForm .= "<br><button class='cpress-btn cpress-btn-secondary cpress-btn-sm' onclick=\"printElement('%cpressID%', '" . $printTitle . "', '" . $cpressStyles . "');\">" . __('Print', 'chordpress') . "</button>\n";864 // $interactionForm .= "<br><button class='cpress-btn cpress-btn-secondary cpress-btn-sm' onclick=\"window.print();\">" . __('Print', 'chordpress') . "</button>\n";865 982 } 866 983 $interactionForm .= "</div>"; 867 $returnText .= $interactionForm . "</div>\n"; 868 } 869 870 $returnText .= "<div id=\"%cpressID%\" class=\"cpress\">\n"; 871 872 /** 873 * Print header if directives exist 874 */ 875 $randId = $this->random_string(true); 876 if (strlen($this->arrDirectives['title']) && !$this->hideTitle) { 877 $cpressID = str_replace(' ', '-', strtolower(trim($this->arrDirectives['title']))) . '-' . $randId; 878 $returnText = str_replace('%cpressID%', $cpressID, $returnText); 879 $returnText .= '<' . $this->titleLevel . '>' . $this->arrDirectives['title'] . '</' . $this->titleLevel . ">\n"; 880 } else { 881 $cpressID = 'ccpress-id-' . $randId; 882 $returnText = str_replace('%cpressID%', $cpressID, $returnText); 883 } 884 885 if (strlen($this->arrDirectives['subtitle']) && !$this->hideSubtitle) { 886 $returnText .= '<' . $this->subtitleLevel . '>' . $this->arrDirectives['subtitle'] . '</' . $this->subtitleLevel . ">\n"; 887 } 888 889 if ( 890 strlen($this->arrDirectives['album']) || 891 strlen($this->arrDirectives['artist']) || 892 strlen($this->arrDirectives['capo']) || 893 strlen($this->arrDirectives['composer']) || 894 strlen($this->arrDirectives['key']) || 895 strlen($this->arrDirectives['tempo']) || 896 strlen($this->arrDirectives['time']) || 897 strlen($this->arrDirectives['year']) 898 ) { 899 $returnText .= "<div class=\"cpress_meta\">\n"; 900 if (strlen($this->arrDirectives['composer']) && !$this->hideComposer) $returnText .= esc_html(__('Composer', 'chordpress')) . ': ' . $this->arrDirectives['composer'] . "<br>\n"; 901 if (strlen($this->arrDirectives['artist']) && !$this->hideArtist) $returnText .= esc_html(__('Artist', 'chordpress')) . ': ' . $this->arrDirectives['artist'] . "<br>\n"; 902 if (strlen($this->arrDirectives['year']) && !$this->hideYear) $returnText .= esc_html(__('Year', 'chordpress')) . ': ' . $this->arrDirectives['year'] . "<br>\n"; 903 if (strlen($this->arrDirectives['album']) && !$this->hideAlbum) $returnText .= esc_html(__('Album', 'chordpress')) . ': ' . $this->arrDirectives['album'] . "<br>\n"; 904 905 if (strlen($this->arrDirectives['key']) && !$this->hideKey) { 906 $returnText .= esc_html(__('Key (original)', 'chordpress')) . ': ' . $this->arrDirectives['key'] . "<br>\n"; 907 $returnText .= esc_html(__('Key (transposed)', 'chordpress')) . ': <span class="chord-hidable-%cpressID% key-%cpressID%-0">' . $this->arrDirectives['key'] . '</span>'; 908 for ($t = 1; $t <= 11; $t++) { 909 $returnText .= '<span class="chord-hidable-%cpressID% key-%cpressID%-' . $t . '" style="display:none">' . $this->arrTransposeValues[$this->arrDirectives['key']][$t] . '</span>'; 910 } 911 $returnText .= "<br>\n"; 984 } 985 $interactionForm .= "<div class='cpress-col cpress-pr-0'>"; 986 if (!$this->hidePrint) { 987 $printTitle = 'ChordPress SongSheet'; 988 if (strlen($this->arrDirectives['title']) && !$this->hideTitle) { 989 $printTitle = $this->arrDirectives['title']; 912 990 } 913 914 if (strlen($this->arrDirectives['time'])) $returnText .= esc_html(__('Time', 'chordpress')) . ': ' . $this->arrDirectives['time'] . "<br>\n"; 915 if (strlen($this->arrDirectives['tempo'])) $returnText .= esc_html(__('Tempo', 'chordpress')) . ': ' . $this->arrDirectives['tempo'] . "<br>\n"; 916 if (strlen($this->arrDirectives['capo'])) $returnText .= esc_html(__('Capo', 'chordpress')) . ': ' . $this->arrDirectives['capo'] . "<br>\n"; 917 $returnText = preg_replace('/<br>$/', '', $returnText); // Remove last <br> 918 $returnText .= "</div>\n"; 919 } 920 921 /** 922 * Go through each line and process it 923 */ 924 $this->inMonospace = false; 925 foreach ($text as $line) { 926 if ($this->inMonospace && strpos($line, "{end_of_monospace}") === false) { 927 $returnText .= $line; 928 } else { 929 $returnText .= $this->formatAndDisplayLine($line); 930 } 931 } 932 $returnText = str_replace('%cpressID%', $cpressID, $returnText); 933 934 /** 935 * End of ChordPress song 936 */ 937 $returnText .= "</div>\n<!--end: ChordPress SongSheet-->\n"; 938 939 /** 940 * Build chord sheet if option set to true. 941 */ 942 if ($this->showChordSheet) { 943 $chordSheetText = "\n<!--begin: ChordPress ChordSheet-->\n"; 944 $chordSheetText .= "<div class='cpress_chordsheet'>\n"; 945 $chordSheetText .= "<div><hr></div>\n"; 946 $chordSheetText .= "<p><i>" . esc_html(__('These known chords are used in this song', 'chordpress')) . ".</i></p>"; 947 $this->uniqueChords = array_unique($this->allChords); 948 foreach ($this->uniqueChords as $uc) { 949 if ($postid = $this->find_guitar_chord_post($uc)) { 950 $this->load_guitar_chord($postid); 951 $chordSheetText .= $this->C->createSvgChord(true); 952 } 953 } 954 $chordSheetText .= "</div>\n<div style=\"clear:both; padding: 16px 0 16px 0;\"><hr></div>\n<!--end: ChordPress ChordSheet-->\n\n"; 955 if ($this->showChordSheetOnTop) { 956 $returnText = $chordSheetText . $returnText; 957 } else { 958 $returnText = $returnText . $chordSheetText; 959 } 960 } 961 962 // $this->C->dnd($returnText); 963 return $returnText . "\n\n"; 991 $interactionForm .= "<br><button class='cpress-btn cpress-btn-secondary cpress-btn-sm' onclick=\"printElement('%cpressID%', '" . $printTitle . "', '" . $this->songsheetStyles . "');\">" . __('Print', 'chordpress') . "</button>\n"; 992 } 993 $interactionForm .= "</div>"; 994 return $interactionForm; 964 995 } 965 996 … … 976 1007 * @since 1.0.0 977 1008 */ 978 public function formatAndDisplayLine( $line){1009 public function formatAndDisplayLine(string $line): string { 979 1010 $returnText = ""; 980 1011 … … 1261 1292 * @since 1.0.0 1262 1293 */ 1263 private function stripTags( $string){1294 private function stripTags(string $string): string { 1264 1295 $retString = ""; 1265 1296 $isVisible = true; … … 1289 1320 * @since 1.0.0 1290 1321 */ 1291 public function formatChord( $ch){1322 public function formatChord(string $ch): string { 1292 1323 $useFlats = false; 1293 1324 if (strlen($ch) == 0) return ''; … … 1352 1383 * Processes a Chromatic harmonica note and returns the formatted HTML. 1353 1384 * 1354 * @param string $note - Chromatic note, e.g. "1" or "1s" or "-1" or "-1s". 1385 * @param string $note - Chromatic note, e.g. "1" or "1s" or "-1" or "-1s". 1386 * @param int $transpose - Numeric transpose value, 0-11. 1355 1387 * 1356 1388 * @return string - Transposed chromatic note 1357 1389 * @since 2.8.0 1358 1390 */ 1359 public function transposeChromaticNote( $note, $transpose){1391 public function transposeChromaticNote(string $note, int $transpose): string { 1360 1392 if (strlen($note) == 0) return ''; 1361 1393 if ($transpose === 0 || $transpose > 11) return $note; … … 1396 1428 * @since 1.0.0 1397 1429 */ 1398 public function formatRemainder( $remainder){1430 public function formatRemainder(string $remainder): string { 1399 1431 $indexOfSlash = strpos($remainder, '/'); 1400 1432 if ($indexOfSlash === false) return $remainder; … … 1465 1497 * @since 1.0.0 1466 1498 */ 1467 public function noteToNumber( $n){1499 public function noteToNumber(string $n): int { 1468 1500 $regularNotation = array( 1469 1501 'A' => 0, … … 1515 1547 * @since 1.0.0 1516 1548 */ 1517 public function numberToNote( $n, $useFlats = false){1549 public function numberToNote(string $n, bool $useFlats = false): string { 1518 1550 $retVal = ''; 1519 1551 … … 1586 1618 * @since 3.8.0 1587 1619 */ 1588 public function translateHarmonicaNote( $note, $from, $to){1620 public function translateHarmonicaNote(string $note, string $from, string $to): string { 1589 1621 1590 1622 $from = strtolower($from); … … 1687 1719 * @since 1.0.0 1688 1720 */ 1689 public function getDisplayHBNotation() {1721 public function getDisplayHBNotation(): bool { 1690 1722 return $this->displayHBNotation; 1691 1723 } … … 1702 1734 * @since 1.0.0 1703 1735 */ 1704 public function setDisplayHBNotation( $g){1736 public function setDisplayHBNotation(bool $g): void { 1705 1737 $this->displayHBNotation = $g; 1706 1738 } … … 1716 1748 * @since 1.0.0 1717 1749 */ 1718 public function getFloat() {1750 public function getFloat(): string { 1719 1751 return $this->float; 1720 1752 } … … 1731 1763 * @since 1.0.0 1732 1764 */ 1733 public function setFloat( $f){1765 public function setFloat(string $f): void { 1734 1766 $this->float = $f; 1735 1767 } … … 1745 1777 * @since 3.8.0 1746 1778 */ 1747 public function getHarmonica() {1779 public function getHarmonica(): string { 1748 1780 return $this->harmonica; 1749 1781 } … … 1760 1792 * @since 3.8.0 1761 1793 */ 1762 public function setHarmonica( $h){1794 public function setHarmonica(string $h): void { 1763 1795 if (in_array(strtolower($h), $this->harmonicaTypes)) { 1764 1796 $this->harmonica = strtolower($h); … … 1778 1810 * @since 1.0.0 1779 1811 */ 1780 public function getHBNotation() {1812 public function getHBNotation(): string { 1781 1813 return $this->hbNotation; 1782 1814 } … … 1793 1825 * @since 1.0.0 1794 1826 */ 1795 public function setHBNotation( $g){1827 public function setHBNotation(string $g): void { 1796 1828 $this->hbNotation = $g; 1797 1829 } … … 1807 1839 * @since 3.5.0 1808 1840 */ 1809 public function getHideChords() {1841 public function getHideChords(): string { 1810 1842 return $this->hideChords; 1811 1843 } … … 1822 1854 * @since 3.5.0 1823 1855 */ 1824 public function setHideChords( $g){1856 public function setHideChords(string $g): void { 1825 1857 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 1826 1858 $this->hideChords = true; … … 1840 1872 * @since 3.5.0 1841 1873 */ 1842 public function getHideComments() {1874 public function getHideComments(): string { 1843 1875 return $this->hideComments; 1844 1876 } … … 1855 1887 * @since 3.5.0 1856 1888 */ 1857 public function setHideComments( $g){1889 public function setHideComments(string $g): void { 1858 1890 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 1859 1891 $this->hideComments = 1; … … 1873 1905 * @since 3.5.0 1874 1906 */ 1875 public function getHideComposer() {1907 public function getHideComposer(): string { 1876 1908 return $this->hideComposer; 1877 1909 } … … 1888 1920 * @since 3.5.0 1889 1921 */ 1890 public function setHideComposer( $g){1922 public function setHideComposer(string $g): void { 1891 1923 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 1892 1924 $this->hideComposer = 1; … … 1906 1938 * @since 3.5.0 1907 1939 */ 1908 public function getHidePrint() {1940 public function getHidePrint(): string { 1909 1941 return $this->hidePrint; 1910 1942 } … … 1921 1953 * @since 3.5.0 1922 1954 */ 1923 public function setHidePrint( $g){1955 public function setHidePrint(string $g): void { 1924 1956 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 1925 1957 $this->hidePrint = 1; … … 1939 1971 * @since 3.5.0 1940 1972 */ 1941 public function getHideSubtitle() {1973 public function getHideSubtitle(): string { 1942 1974 return $this->hideSubtitle; 1943 1975 } … … 1954 1986 * @since 3.5.0 1955 1987 */ 1956 public function setHideSubtitle( $g){1988 public function setHideSubtitle(string $g): void { 1957 1989 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 1958 1990 $this->hideSubtitle = 1; … … 1972 2004 * @since 3.5.0 1973 2005 */ 1974 public function getHideTitle() {2006 public function getHideTitle(): string { 1975 2007 return $this->hideTitle; 1976 2008 } … … 1987 2019 * @since 3.5.0 1988 2020 */ 1989 public function setHideTitle( $g){2021 public function setHideTitle(string $g): void { 1990 2022 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 1991 2023 $this->hideTitle = 1; … … 2005 2037 * @since 3.8.1 2006 2038 */ 2007 public function getFontsize() {2039 public function getFontsize(): string { 2008 2040 return $this->hideFontsize; 2009 2041 } … … 2020 2052 * @since 3.8.1 2021 2053 */ 2022 public function setHideFontsize( $g){2054 public function setHideFontsize(string $g): void { 2023 2055 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 2024 2056 $this->hideFontsize = 1; … … 2038 2070 * @since 3.5.0 2039 2071 */ 2040 public function getHideTranspose() {2072 public function getHideTranspose(): string { 2041 2073 return $this->hideTranspose; 2042 2074 } … … 2053 2085 * @since 3.5.0 2054 2086 */ 2055 public function setHideTranspose( $g){2087 public function setHideTranspose(string $g): void { 2056 2088 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 2057 2089 $this->hideTranspose = 1; … … 2071 2103 * @since 3.6.0 2072 2104 */ 2073 public function getNumericTranspose() {2105 public function getNumericTranspose(): string { 2074 2106 return $this->showNumericTranspose; 2075 2107 } … … 2086 2118 * @since 3.6.0 2087 2119 */ 2088 public function setNumericTranspose( $g){2120 public function setNumericTranspose(string $g): void { 2089 2121 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 2090 2122 $this->showNumericTranspose = 1; … … 2104 2136 * @since 3.6.0 2105 2137 */ 2106 public function getFixedInteraction() {2138 public function getFixedInteraction(): string { 2107 2139 return $this->fixedInteraction; 2108 2140 } … … 2119 2151 * @since 3.6.0 2120 2152 */ 2121 public function setFixedInteraction( $g){2153 public function setFixedInteraction(string $g): void { 2122 2154 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 2123 2155 $this->fixedInteraction = 1; … … 2137 2169 * @since 3.5.0 2138 2170 */ 2139 public function getHideYear() {2171 public function getHideYear(): string { 2140 2172 return $this->hideYear; 2141 2173 } … … 2152 2184 * @since 3.5.0 2153 2185 */ 2154 public function setHideYear( $g){2186 public function setHideYear(string $g): void { 2155 2187 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 2156 2188 $this->hideYear = 1; … … 2170 2202 * @since 1.0.0 2171 2203 */ 2172 public function getInteractive() {2204 public function getInteractive(): string { 2173 2205 return $this->interactive; 2174 2206 } … … 2185 2217 * @since 1.0.0 2186 2218 */ 2187 public function setInteractive( $i){2219 public function setInteractive(string $i): void { 2188 2220 $this->interactive = $i; 2189 2221 } … … 2199 2231 * @since 3.5.0 2200 2232 */ 2201 public function getShowChordSheet() {2233 public function getShowChordSheet(): string { 2202 2234 return $this->showChordSheet; 2203 2235 } … … 2214 2246 * @since 3.5.0 2215 2247 */ 2216 public function setShowChordSheet( $g){2248 public function setShowChordSheet(string $g): void { 2217 2249 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 2218 2250 $this->showChordSheet = 1; … … 2232 2264 * @since 3.5.0 2233 2265 */ 2234 public function getShowChordSheetOnTop() {2266 public function getShowChordSheetOnTop(): string { 2235 2267 return $this->showChordSheetOnTop; 2236 2268 } … … 2247 2279 * @since 3.5.0 2248 2280 */ 2249 public function setShowChordSheetOnTop( $g){2281 public function setShowChordSheetOnTop(string $g): void { 2250 2282 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 2251 2283 $this->showChordSheetOnTop = 1; … … 2265 2297 * @since 1.0.0 2266 2298 */ 2267 public function getTranspose() {2299 public function getTranspose(): int { 2268 2300 return $this->transpose; 2269 2301 } … … 2280 2312 * @since 1.0.0 2281 2313 */ 2282 public function setTranspose( $t){2314 public function setTranspose(int $t): void { 2283 2315 $this->transpose = $t; 2284 2316 } … … 2295 2327 * @return integer - Post ID or NULL 2296 2328 */ 2297 private function find_guitar_chord_post( $shortname){2329 private function find_guitar_chord_post(string $shortname): int { 2298 2330 $query_args = array( 2299 2331 'posts_per_page' => 1, … … 2322 2354 * @return void 2323 2355 */ 2324 private function load_guitar_chord( $postid){2356 private function load_guitar_chord(int $postid): void { 2325 2357 $my_chord = array(); 2326 2358 $post = get_post($postid); … … 2361 2393 * @return string - Modal chord dialog HTML 2362 2394 */ 2363 // private function create_modal_chord($postid, $chord) 2364 // { 2395 // private function create_modal_chord(int $postid, string $chord): string { 2365 2396 // $modal_chord = '<!-- <button id="cpress-chord-' . $postid . '-modal-button">Click here to trigger the modal!</button> --> 2366 2397 // <div id="cpress-chord-' . $postid . '-modal" class="cpress-modal"> … … 2405 2436 * @return false|string 2406 2437 */ 2407 private function random_string( $alphaonly = false, $length = 15){2438 private function random_string(bool $alphaonly = false, int $length = 15): string|false { 2408 2439 if ($alphaonly) { 2409 2440 return substr(str_shuffle(str_repeat($x = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length); … … 2424 2455 * @since 3.2.0 2425 2456 */ 2426 private function dnd( $a, $die = true){2457 private function dnd(array $a, bool $die = true): string { 2427 2458 $dump = highlight_string("<?php\n\$data =\n" . var_export($a, true) . ";\n?>"); 2428 if ($die) die($dump); 2429 else return $dump; 2459 if ($die) { 2460 die($dump); 2461 } else { 2462 return $dump; 2463 } 2430 2464 } 2431 2465 } -
chordpress/tags/3.9.3/languages/chordpress.pot
r3298894 r3307608 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Lewe ChordPress 3.9. 0\n"5 "Project-Id-Version: Lewe ChordPress 3.9.2\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/chordpress\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 2025-0 5-22T18:00:03+02:00\n"12 "POT-Creation-Date: 2025-06-06T19:11:35+02:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 14 "X-Generator: WP-CLI 2.4.0\n" … … 550 550 551 551 #: admin/partials/chordpress-admin-options.php:394 552 msgid "With this option selected, the interaction menu will be fixed at the bottom of the page. Note, that this might lead to unexpected results depending on the WordPress theme you use . You can overwrite this setting per shortcut with \"fixedinteraction=yes/no\""552 msgid "With this option selected, the interaction menu will be fixed at the bottom of the page. Note, that this might lead to unexpected results depending on the WordPress theme you use and if you use more than one ChordPress songsheet on a page. You can overwrite this setting per shortcut with \"fixedinteraction=yes/no\"" 553 553 msgstr "" 554 554 … … 1248 1248 msgstr "" 1249 1249 1250 #: includes/class-chordpress-renderer.php:740 1251 msgid "Font" 1252 msgstr "" 1253 1254 #: includes/class-chordpress-renderer.php:767 1255 #: includes/class-chordpress-renderer.php:786 1250 #: includes/class-chordpress-renderer.php:763 1251 msgid "Composer" 1252 msgstr "" 1253 1254 #: includes/class-chordpress-renderer.php:764 1255 msgid "Artist" 1256 msgstr "" 1257 1258 #: includes/class-chordpress-renderer.php:765 1259 msgid "Year" 1260 msgstr "" 1261 1262 #: includes/class-chordpress-renderer.php:766 1263 msgid "Album" 1264 msgstr "" 1265 1266 #: includes/class-chordpress-renderer.php:769 1267 msgid "Key (original)" 1268 msgstr "" 1269 1270 #: includes/class-chordpress-renderer.php:770 1271 msgid "Key (transposed)" 1272 msgstr "" 1273 1274 #: includes/class-chordpress-renderer.php:777 1275 msgid "Time" 1276 msgstr "" 1277 1278 #: includes/class-chordpress-renderer.php:778 1279 msgid "Tempo" 1280 msgstr "" 1281 1282 #: includes/class-chordpress-renderer.php:779 1283 msgid "Capo" 1284 msgstr "" 1285 1286 #: includes/class-chordpress-renderer.php:809 1287 msgid "These known chords are used in this song" 1288 msgstr "" 1289 1256 1290 #: includes/class-chordpress-renderer.php:854 1291 msgid "Font Size" 1292 msgstr "" 1293 1294 #: includes/class-chordpress-renderer.php:881 1295 #: includes/class-chordpress-renderer.php:900 1296 #: includes/class-chordpress-renderer.php:969 1257 1297 msgid "Transpose" 1258 1298 msgstr "" 1259 1299 1260 #: includes/class-chordpress-renderer.php: 7881300 #: includes/class-chordpress-renderer.php:902 1261 1301 msgid "Only works for international key names" 1262 1302 msgstr "" 1263 1303 1264 #: includes/class-chordpress-renderer.php: 8351304 #: includes/class-chordpress-renderer.php:949 1265 1305 msgid "Harmonica" 1266 1306 msgstr "" 1267 1307 1268 #: includes/class-chordpress-renderer.php: 8401308 #: includes/class-chordpress-renderer.php:955 1269 1309 msgid "Only works when using harmonica notation" 1270 1310 msgstr "" 1271 1311 1272 #: includes/class-chordpress-renderer.php: 8421312 #: includes/class-chordpress-renderer.php:957 1273 1313 msgid "Diatonic" 1274 1314 msgstr "" 1275 1315 1276 #: includes/class-chordpress-renderer.php: 8431316 #: includes/class-chordpress-renderer.php:958 1277 1317 msgid "Chromatic" 1278 1318 msgstr "" 1279 1319 1280 #: includes/class-chordpress-renderer.php: 8441320 #: includes/class-chordpress-renderer.php:959 1281 1321 msgid "Tremolo" 1282 1322 msgstr "" 1283 1323 1284 #: includes/class-chordpress-renderer.php: 8701324 #: includes/class-chordpress-renderer.php:989 1285 1325 msgid "Print" 1286 1326 msgstr "" 1287 1327 1288 #: includes/class-chordpress-renderer.php:906 1289 msgid "Composer" 1290 msgstr "" 1291 1292 #: includes/class-chordpress-renderer.php:907 1293 msgid "Artist" 1294 msgstr "" 1295 1296 #: includes/class-chordpress-renderer.php:908 1297 msgid "Year" 1298 msgstr "" 1299 1300 #: includes/class-chordpress-renderer.php:909 1301 msgid "Album" 1302 msgstr "" 1303 1304 #: includes/class-chordpress-renderer.php:912 1305 msgid "Key (original)" 1306 msgstr "" 1307 1308 #: includes/class-chordpress-renderer.php:913 1309 msgid "Key (transposed)" 1310 msgstr "" 1311 1312 #: includes/class-chordpress-renderer.php:920 1313 msgid "Time" 1314 msgstr "" 1315 1316 #: includes/class-chordpress-renderer.php:921 1317 msgid "Tempo" 1318 msgstr "" 1319 1320 #: includes/class-chordpress-renderer.php:922 1321 msgid "Capo" 1322 msgstr "" 1323 1324 #: includes/class-chordpress-renderer.php:952 1325 msgid "These known chords are used in this song" 1326 msgstr "" 1327 1328 #: includes/class-chordpress-renderer.php:1070 1328 #: includes/class-chordpress-renderer.php:1093 1329 1329 msgid "Missing square bracket in line" 1330 1330 msgstr "" -
chordpress/tags/3.9.3/readme.txt
r3307598 r3307608 5 5 Requires at least: 4.0 6 6 Tested up to: 6.8 7 Stable tag: 3.9. 27 Stable tag: 3.9.3 8 8 Requires PHP: 5.2.4 9 9 License: GPLv3 … … 130 130 131 131 == Changelog == 132 = 3.9.3 = 133 * 2025-06-06 134 * Improved interaction menu (but do not use fixed position when more than one song on a page) 135 132 136 = 3.9.2 = 133 137 * 2025-06-02 -
chordpress/trunk/admin/partials/chordpress-admin-options.php
r3243398 r3307608 392 392 <td> 393 393 <input type='checkbox' id='<?php echo $pname; ?>_checkbox_fixed_interaction' name='<?php echo $pname; ?>_checkbox_fixed_interaction' <?php checked(get_option($pname . '_checkbox_fixed_interaction'), 1); ?> value='1'> 394 <p class="description"><?php echo esc_html(__('With this option selected, the interaction menu will be fixed at the bottom of the page. Note, that this might lead to unexpected results depending on the WordPress theme you use . You can overwrite this setting per shortcut with "fixedinteraction=yes/no"', 'chordpress')); ?>.</p>394 <p class="description"><?php echo esc_html(__('With this option selected, the interaction menu will be fixed at the bottom of the page. Note, that this might lead to unexpected results depending on the WordPress theme you use and if you use more than one ChordPress songsheet on a page. You can overwrite this setting per shortcut with "fixedinteraction=yes/no"', 'chordpress')); ?>.</p> 395 395 </td> 396 396 </tr> -
chordpress/trunk/chordpress.php
r3305993 r3307608 19 19 * Plugin URI: https://lewe.gitbook.io/lewe-chordpress/ 20 20 * Description: This plugin renders ChordPro formatted text and chord diagrams in WordPress sites. 21 * Version: 3.9. 221 * Version: 3.9.3 22 22 * Author: George Lewe 23 23 * Author URI: https://www.lewe.com … … 38 38 */ 39 39 define('CHORDPRESS_NAME', 'ChordPress'); 40 define('CHORDPRESS_VERSION', '3.9. 2');40 define('CHORDPRESS_VERSION', '3.9.3'); 41 41 define('CHORDPRESS_AUTHOR', 'George Lewe'); 42 42 define('CHORDPRESS_AUTHOR_URI', 'https://www.lewe.com'); -
chordpress/trunk/includes/class-chordpress-renderer.php
r3305993 r3307608 55 55 * @var array $harmonicaTypes Harmonica types. 56 56 */ 57 private $harmonicaTypes = array( 'tremolo', 'diatonic', 'chromatic' );57 private $harmonicaTypes = [ 'tremolo', 'diatonic', 'chromatic' ]; 58 58 59 59 /** … … 499 499 500 500 private $arrChromaticTranspose = array( 501 '1' => [ '1', '1s', '-1', '-1s', '2', '-2', '-2s', '3', '3s', '-3', '-3s', '-4'],502 '1s' => [ '1s', '-1', '-1s', '2', '-2', '-2s', '3', '3s', '-3', '-3s', '-4', '4' ],503 '-1' => [ '-1', '-1s', '2', '-2', '-2s', '3', '3s', '-3', '-3s', '-4', '4', '4s' ],504 '-1s' => [ '-1s', '2', '-2', '-2s', '3', '3s', '-3', '-3s', '-4', '4', '4s', '-5' ],505 '2' => [ '2', '-2', '-2s', '3', '3s', '-3', '-3s', '-4', '4', '4s', '-5', '-5s' ],506 '-2' => [ '-2', '-2s', '3', '3s', '-3', '-3s', '-4', '4', '4s', '-5', '-5s', '6' ],507 '-2s' => [ '-2s', '3', '3s', '-3', '-3s', '-4', '4', '4s', '-5', '-5s', '6', '-6' ],508 '3' => [ '3', '3s', '-3', '-3s', '-4', '4', '4s', '-5', '-5s', '6', '-6', '-6s' ],509 '3s' => [ '3s', '-3', '-3s', '-4', '4', '4s', '-5', '-5s', '6', '-6', '-6s', '7' ],510 '-3' => [ '-3', '-3s', '-4', '4', '4s', '-5', '-5s', '6', '-6', '-6s', '7', '7s' ],511 '-3s' => [ '-3s', '-4', '4', '4s', '-5', '-5s', '6', '-6', '-6s', '7', '7s', '-7' ],512 '-4' => [ '-4', '4', '4s', '-5', '-5s', '6', '-6', '-6s', '7', '7s', '-7', '-7s' ],513 '4' => [ '4', '4s', '-5', '-5s', '6', '-6', '-6s', '7', '7s', '-7', '-7s', '-8' ],514 '4s' => [ '4s', '-5', '-5s', '6', '-6', '-6s', '7', '7s', '-7', '-7s', '-8', '8' ],515 '-5' => [ '-5', '-5s', '6', '-6', '-6s', '7', '7s', '-7', '-7s', '-8', '8', '9' ],516 '-5s' => [ '-5s', '6', '-6', '-6s', '7', '7s', '-7', '-7s', '-8', '8', '9', '9s' ],517 '6' => [ '6', '-6', '-6s', '7', '7s', '-7', '-7s', '-8', '8', '9', '9s', '-9' ],518 '-6' => [ '-6', '-6s', '7', '7s', '-7', '-7s', '-8', '8', '9', '9s', '-9', '-9s' ],519 '-6s' => [ '-6s', '7', '7s', '-7', '-7s', '-8', '8', '9', '9s', '-9', '-9s', '10' ],520 '7' => [ '7', '7s', '-7', '-7s', '-8', '8', '9', '9s', '-9', '-9s', '10', '-10' ],521 '7s' => [ '7s', '-7', '-7s', '-8', '8', '9', '9s', '-9', '-9s', '10', '-10', '-10s' ],522 '-7' => [ '-7', '-7s', '-8', '8', '9', '9s', '-9', '-9s', '10', '-10', '-10s', '11' ],523 '-7s' => [ '-7s', '-8', '8', '9', '9s', '-9', '-9s', '10', '-10', '-10s', '11', '11s' ],524 '-8' => [ '-8', '8', '9', '9s', '-9', '-9s', '10', '-10', '-10s', '11', '11s', '-11' ],525 '8' => [ '8', '9', '9s', '-9', '-9s', '10', '-10', '-10s', '11', '11s', '-11', '-11s' ],526 '9' => [ '9', '9s', '-9', '-9s', '10', '-10', '-10s', '11', '11s', '-11', '-11s', '-12' ],527 '9s' => [ '9s', '-9', '-9s', '10', '-10', '-10s', '11', '11s', '-11', '-11s', '-12', '12' ],528 '-9' => [ '-9', '-9s', '10', '-10', '-10s', '11', '11s', '-11', '-11s', '-12', '12', '12s' ],529 '-9s' => [ '-9s', '10', '-10', '-10s', '11', '11s', '-11', '-11s', '-12', '12', '12s', ' ' ],530 '10' => [ '10', '-10', '-10s', '11', '11s', '-11', '-11s', '-12', '12', '12s', ' ', ' ' ],531 '-10' => [ '-10', '-10s', '11', '11s', '-11', '-11s', '-12', '12', '12s', ' ', ' ', ' ' ],532 '-10s' => [ '-10s', '11', '11s', '-11', '-11s', '-12', '12', '12s', ' ', ' ', ' ', ' ' ],533 '11' => [ '11', '11s', '-11', '-11s', '-12', '12', '12s', ' ', ' ', ' ', ' ', ' ' ],534 '11s' => [ '11s', '-11', '-11s', '-12', '12', '12s', ' ', ' ', ' ', ' ', ' ', ' ' ],535 '-11' => [ '-11', '-11s', '-12', '12', '12s', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],536 '-11s' => [ '-11s', '-12', '12', '12s', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],537 '-12' => [ '-12', '12', '12s', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],538 '12' => [ '12', '12s', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],539 '12s' => [ '12s', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],501 '1' => [ '1', '1s', '-1', '-1s', '2', '-2', '-2s', '3', '3s', '-3', '-3s', '-4' ], 502 '1s' => [ '1s', '-1', '-1s', '2', '-2', '-2s', '3', '3s', '-3', '-3s', '-4', '4' ], 503 '-1' => [ '-1', '-1s', '2', '-2', '-2s', '3', '3s', '-3', '-3s', '-4', '4', '4s' ], 504 '-1s' => [ '-1s', '2', '-2', '-2s', '3', '3s', '-3', '-3s', '-4', '4', '4s', '-5' ], 505 '2' => [ '2', '-2', '-2s', '3', '3s', '-3', '-3s', '-4', '4', '4s', '-5', '-5s' ], 506 '-2' => [ '-2', '-2s', '3', '3s', '-3', '-3s', '-4', '4', '4s', '-5', '-5s', '6' ], 507 '-2s' => [ '-2s', '3', '3s', '-3', '-3s', '-4', '4', '4s', '-5', '-5s', '6', '-6' ], 508 '3' => [ '3', '3s', '-3', '-3s', '-4', '4', '4s', '-5', '-5s', '6', '-6', '-6s' ], 509 '3s' => [ '3s', '-3', '-3s', '-4', '4', '4s', '-5', '-5s', '6', '-6', '-6s', '7' ], 510 '-3' => [ '-3', '-3s', '-4', '4', '4s', '-5', '-5s', '6', '-6', '-6s', '7', '7s' ], 511 '-3s' => [ '-3s', '-4', '4', '4s', '-5', '-5s', '6', '-6', '-6s', '7', '7s', '-7' ], 512 '-4' => [ '-4', '4', '4s', '-5', '-5s', '6', '-6', '-6s', '7', '7s', '-7', '-7s' ], 513 '4' => [ '4', '4s', '-5', '-5s', '6', '-6', '-6s', '7', '7s', '-7', '-7s', '-8' ], 514 '4s' => [ '4s', '-5', '-5s', '6', '-6', '-6s', '7', '7s', '-7', '-7s', '-8', '8' ], 515 '-5' => [ '-5', '-5s', '6', '-6', '-6s', '7', '7s', '-7', '-7s', '-8', '8', '9' ], 516 '-5s' => [ '-5s', '6', '-6', '-6s', '7', '7s', '-7', '-7s', '-8', '8', '9', '9s' ], 517 '6' => [ '6', '-6', '-6s', '7', '7s', '-7', '-7s', '-8', '8', '9', '9s', '-9' ], 518 '-6' => [ '-6', '-6s', '7', '7s', '-7', '-7s', '-8', '8', '9', '9s', '-9', '-9s' ], 519 '-6s' => [ '-6s', '7', '7s', '-7', '-7s', '-8', '8', '9', '9s', '-9', '-9s', '10' ], 520 '7' => [ '7', '7s', '-7', '-7s', '-8', '8', '9', '9s', '-9', '-9s', '10', '-10' ], 521 '7s' => [ '7s', '-7', '-7s', '-8', '8', '9', '9s', '-9', '-9s', '10', '-10', '-10s' ], 522 '-7' => [ '-7', '-7s', '-8', '8', '9', '9s', '-9', '-9s', '10', '-10', '-10s', '11' ], 523 '-7s' => [ '-7s', '-8', '8', '9', '9s', '-9', '-9s', '10', '-10', '-10s', '11', '11s' ], 524 '-8' => [ '-8', '8', '9', '9s', '-9', '-9s', '10', '-10', '-10s', '11', '11s', '-11' ], 525 '8' => [ '8', '9', '9s', '-9', '-9s', '10', '-10', '-10s', '11', '11s', '-11', '-11s' ], 526 '9' => [ '9', '9s', '-9', '-9s', '10', '-10', '-10s', '11', '11s', '-11', '-11s', '-12' ], 527 '9s' => [ '9s', '-9', '-9s', '10', '-10', '-10s', '11', '11s', '-11', '-11s', '-12', '12' ], 528 '-9' => [ '-9', '-9s', '10', '-10', '-10s', '11', '11s', '-11', '-11s', '-12', '12', '12s' ], 529 '-9s' => [ '-9s', '10', '-10', '-10s', '11', '11s', '-11', '-11s', '-12', '12', '12s', ' ' ], 530 '10' => [ '10', '-10', '-10s', '11', '11s', '-11', '-11s', '-12', '12', '12s', ' ', ' ' ], 531 '-10' => [ '-10', '-10s', '11', '11s', '-11', '-11s', '-12', '12', '12s', ' ', ' ', ' ' ], 532 '-10s' => [ '-10s', '11', '11s', '-11', '-11s', '-12', '12', '12s', ' ', ' ', ' ', ' ' ], 533 '11' => [ '11', '11s', '-11', '-11s', '-12', '12', '12s', ' ', ' ', ' ', ' ', ' ' ], 534 '11s' => [ '11s', '-11', '-11s', '-12', '12', '12s', ' ', ' ', ' ', ' ', ' ', ' ' ], 535 '-11' => [ '-11', '-11s', '-12', '12', '12s', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ], 536 '-11s' => [ '-11s', '-12', '12', '12s', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ], 537 '-12' => [ '-12', '12', '12s', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ], 538 '12' => [ '12', '12s', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ], 539 '12s' => [ '12s', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ], 540 540 ); 541 541 … … 558 558 */ 559 559 private $allowedChordPrefixes = array( '~', '|', '/', '.', '-', '+', '1', '2', '3', '4', '5', '6', '7', '8', '9' ); 560 561 /** 562 * Holds the styles for the songsheet 563 * 564 * @since 3.9.3 565 * @access private 566 * @var string 567 */ 568 private $songsheetStyles = ''; 560 569 561 570 /** … … 616 625 * Get the ChordPro directives and store the supported ones in an array. 617 626 * 618 * @param object $text - Text inside shortcode wrapper.627 * @param array $text - Text inside shortcode wrapper in an array (each line is an array element). 619 628 * 620 629 * @since 1.0.0 621 630 */ 622 public function getDirectives( $text) {631 public function getDirectives(array $text) { 623 632 foreach ($text as $line) { 624 633 $line = trim($this->stripTags($line)); … … 698 707 * </div> 699 708 * 700 * @param object $text - Text inside shortcode wrapper.709 * @param array $text - Text inside shortcode wrapper in an array (each line is an array element). 701 710 * 702 711 * @return string - Formatted HTML of the ChordPro text. 703 712 * @since 1.0.0 704 713 */ 705 public function displayText( $text): string {706 /** 707 * Start of ChordPress wrapper708 */ 709 $ cpressStyles = "<style>div.cpress { float: " . $this->float . "; } div.cpress_line { " . $this->lineStyle . "; } div.cpress_line_section { display: inline; float: left; } div.cpress_line_section .chord .chordshort { " . $this->chordStyle . "; } div.cpress_line_section .lyric { " . $this->lyricsStyle . "; } div.cpress_chorus { " . $this->chorusStyle . "; } div.cpress_verse { " . $this->verseStyle . "; } div.cpress_clear { clear: both; } div.cpress_meta { " . $this->metaStyle . "; } div.cpress_interaction { float: right; } div.cpress_interaction select { width: auto; } span.cpress_comment { " . $this->commentStyle . "; } div.cpress_chordsheet { text-align: center; }</style>";710 711 $ returnText= "\n\n714 public function displayText(array $text): string { 715 /** 716 * The styles need to be a one-line string in a separate variable because it is passed to the Javascript print function 717 */ 718 $this->songsheetStyles = "<style>div.cpress { float: " . $this->float . "; } div.cpress_line { " . $this->lineStyle . "; } div.cpress_line_section { display: inline; float: left; } div.cpress_line_section .chord .chordshort { " . $this->chordStyle . "; } div.cpress_line_section .lyric { " . $this->lyricsStyle . "; } div.cpress_chorus { " . $this->chorusStyle . "; } div.cpress_verse { " . $this->verseStyle . "; } div.cpress_clear { clear: both; } div.cpress_meta { " . $this->metaStyle . "; } div.cpress_interaction { float: right; } div.cpress_interaction select { width: auto; } span.cpress_comment { " . $this->commentStyle . "; } div.cpress_chordsheet { text-align: center; }</style>"; 719 720 $songsheetHtml = "\n\n 712 721 <!--begin: ChordPress SongSheet --> 713 722 <div> 714 " . $ cpressStyles . "723 " . $this->songsheetStyles . " 715 724 </div>\n"; 716 725 … … 719 728 */ 720 729 if (in_array(strtolower($this->interactive), array( "yes", "1", "true" ))) { 721 $interactionForm = "<div class=\"cpress-interaction cpress-row"; 722 if ($this->fixedInteraction) { 723 $interactionForm .= " fixed"; 730 $songsheetHtml .= $this->buildInteractionMenu(); 731 } 732 733 $songsheetHtml .= "<div id=\"%cpressID%\" class=\"cpress\">\n"; 734 735 /** 736 * Print header and subtitle if directives exist 737 */ 738 $randId = $this->random_string(true); 739 if (strlen($this->arrDirectives['title']) && !$this->hideTitle) { 740 $cpressID = str_replace(' ', '-', strtolower(trim($this->arrDirectives['title']))) . '-' . $randId; 741 $songsheetHtml = str_replace('%cpressID%', $cpressID, $songsheetHtml); 742 $songsheetHtml .= '<' . $this->titleLevel . '>' . $this->arrDirectives['title'] . '</' . $this->titleLevel . ">\n"; 743 } else { 744 $cpressID = 'ccpress-id-' . $randId; 745 $songsheetHtml = str_replace('%cpressID%', $cpressID, $songsheetHtml); 746 } 747 if (strlen($this->arrDirectives['subtitle']) && !$this->hideSubtitle) { 748 $songsheetHtml .= '<' . $this->subtitleLevel . '>' . $this->arrDirectives['subtitle'] . '</' . $this->subtitleLevel . ">\n"; 749 } 750 751 /** 752 * Print meta data if directives exist 753 */ 754 if ( 755 strlen($this->arrDirectives['album']) || 756 strlen($this->arrDirectives['artist']) || 757 strlen($this->arrDirectives['capo']) || 758 strlen($this->arrDirectives['composer']) || 759 strlen($this->arrDirectives['key']) || 760 strlen($this->arrDirectives['tempo']) || 761 strlen($this->arrDirectives['time']) || 762 strlen($this->arrDirectives['year']) 763 ) { 764 $songsheetHtml .= "<div class=\"cpress_meta\">\n"; 765 if (strlen($this->arrDirectives['composer']) && !$this->hideComposer) $songsheetHtml .= esc_html(__('Composer', 'chordpress')) . ': ' . $this->arrDirectives['composer'] . "<br>\n"; 766 if (strlen($this->arrDirectives['artist']) && !$this->hideArtist) $songsheetHtml .= esc_html(__('Artist', 'chordpress')) . ': ' . $this->arrDirectives['artist'] . "<br>\n"; 767 if (strlen($this->arrDirectives['year']) && !$this->hideYear) $songsheetHtml .= esc_html(__('Year', 'chordpress')) . ': ' . $this->arrDirectives['year'] . "<br>\n"; 768 if (strlen($this->arrDirectives['album']) && !$this->hideAlbum) $songsheetHtml .= esc_html(__('Album', 'chordpress')) . ': ' . $this->arrDirectives['album'] . "<br>\n"; 769 770 if (strlen($this->arrDirectives['key']) && !$this->hideKey) { 771 $songsheetHtml .= esc_html(__('Key (original)', 'chordpress')) . ': ' . $this->arrDirectives['key'] . "<br>\n"; 772 $songsheetHtml .= esc_html(__('Key (transposed)', 'chordpress')) . ': <span class="chord-hidable-%cpressID% key-%cpressID%-0">' . $this->arrDirectives['key'] . '</span>'; 773 for ($t = 1; $t <= 11; $t++) { 774 $songsheetHtml .= '<span class="chord-hidable-%cpressID% key-%cpressID%-' . $t . '" style="display:none">' . $this->arrTransposeValues[$this->arrDirectives['key']][$t] . '</span>'; 775 } 776 $songsheetHtml .= "<br>\n"; 724 777 } 725 $interactionForm .= "\">"; 726 727 if (!$this->hideFontsize) { 728 $interactionForm .= "<div class='cpress-col cpress-pl-0'>" . __('Font', 'chordpress') . "<br> 778 779 if (strlen($this->arrDirectives['time'])) $songsheetHtml .= esc_html(__('Time', 'chordpress')) . ': ' . $this->arrDirectives['time'] . "<br>\n"; 780 if (strlen($this->arrDirectives['tempo'])) $songsheetHtml .= esc_html(__('Tempo', 'chordpress')) . ': ' . $this->arrDirectives['tempo'] . "<br>\n"; 781 if (strlen($this->arrDirectives['capo'])) $songsheetHtml .= esc_html(__('Capo', 'chordpress')) . ': ' . $this->arrDirectives['capo'] . "<br>\n"; 782 $songsheetHtml = preg_replace('/<br>$/', '', $songsheetHtml); // Remove last <br> 783 $songsheetHtml .= "</div>\n"; 784 } 785 786 /** 787 * Go through each line and process it 788 */ 789 $this->inMonospace = false; 790 foreach ($text as $line) { 791 if ($this->inMonospace && strpos($line, "{end_of_monospace}") === false) { 792 $songsheetHtml .= $line; 793 } else { 794 $songsheetHtml .= $this->formatAndDisplayLine($line); 795 } 796 } 797 $songsheetHtml = str_replace('%cpressID%', $cpressID, $songsheetHtml); 798 799 /** 800 * End of ChordPress song 801 */ 802 $songsheetHtml .= "</div>\n<!--end: ChordPress SongSheet-->\n"; 803 804 /** 805 * Build chord sheet if option set to true. 806 */ 807 if ($this->showChordSheet) { 808 $chordSheetText = "\n<!--begin: ChordPress ChordSheet-->\n"; 809 $chordSheetText .= "<div class='cpress_chordsheet'>\n"; 810 $chordSheetText .= "<div><hr></div>\n"; 811 $chordSheetText .= "<p><i>" . esc_html(__('These known chords are used in this song', 'chordpress')) . ".</i></p>"; 812 $this->uniqueChords = array_unique($this->allChords); 813 foreach ($this->uniqueChords as $uc) { 814 if ($postid = $this->find_guitar_chord_post($uc)) { 815 $this->load_guitar_chord($postid); 816 $chordSheetText .= $this->C->createSvgChord(true); 817 } 818 } 819 $chordSheetText .= "</div>\n<div style=\"clear:both; padding: 16px 0 16px 0;\"><hr></div>\n<!--end: ChordPress ChordSheet-->\n\n"; 820 if ($this->showChordSheetOnTop) { 821 $songsheetHtml = $chordSheetText . $songsheetHtml; 822 } else { 823 $songsheetHtml = $songsheetHtml . $chordSheetText; 824 } 825 } 826 827 // $this->C->dnd($songsheetHtml); 828 return $songsheetHtml . "\n\n"; 829 } 830 831 /** 832 * -------------------------------------------------------------------------- 833 * Builds the Interactive Menu 834 * -------------------------------------------------------------------------- 835 * 836 * Builds the interaction menu for the ChordPress song sheet. 837 * 838 * This function generates the HTML for the interaction menu, which includes 839 * options for font size adjustment, transposition, and printing. The menu 840 * can be fixed at the bottom of the page if the `fixedInteraction` property 841 * is set. The function also handles harmonica-specific options if applicable. 842 * 843 * @return string The HTML string for the interaction menu. 844 * @since 3.9.2 845 * @access private 846 * 847 */ 848 private function buildInteractionMenu(): string { 849 $interactionForm = "<div class=\"cpress-interaction cpress-row"; 850 if ($this->fixedInteraction) { 851 $interactionForm .= " fixed"; 852 } 853 $interactionForm .= "\">"; 854 855 if (!$this->hideFontsize) { 856 $interactionForm .= "<div class='cpress-col cpress-mb-2'>" . __('Font Size', 'chordpress') . "<br> 729 857 <div class='cpress-btn-group' role='group'> 730 858 <button type='button' class='cpress-btn cpress-btn-secondary cpress-btn-sm' onclick=\"changeFontSize('%cpressID%', -5);\">-</button> … … 733 861 </div> 734 862 </div>"; 735 } 736 737 if (!$this->hideTranspose) { 738 $interactionForm .= "<div class='cpress-col' style='display: inline-block;'>"; 739 740 if (!$this->harmonica) { 863 } 864 865 if (!$this->hideTranspose) { 866 $interactionForm .= "<div class='cpress-col' style='display: inline-block;'>"; 867 868 if (!$this->harmonica) { 869 // 870 // Guitar chords 871 // 872 if ($this->showNumericTranspose && !$this->harmonica) { 741 873 // 742 // Guitar chords874 // Let's see if a 'Key' directive was given. If so, we can add the transposed keys to the list. 743 875 // 744 if ($this->showNumericTranspose && !$this->harmonica) { 745 // 746 // Let's see if a 'Key' directive was given. If so, we can add the transposed keys to the list. 747 // 748 if (strlen($this->arrDirectives['key']) && in_array($this->arrDirectives['key'], $this->arrKeys)) { 749 $songKey = "'" . $this->arrDirectives['key'] . "'"; 750 $initialText = '0 (' . $this->arrDirectives['key'] . ')'; 751 } else { 752 $songKey = "''"; 753 $initialText = '0'; 754 } 755 $interactionForm .= __('Transpose', 'chordpress') . "<br> 876 if (strlen($this->arrDirectives['key']) && in_array($this->arrDirectives['key'], $this->arrKeys)) { 877 $songKey = "'" . $this->arrDirectives['key'] . "'"; 878 $initialText = '0 (' . $this->arrDirectives['key'] . ')'; 879 } else { 880 $songKey = "''"; 881 $initialText = '0'; 882 } 883 $interactionForm .= __('Transpose', 'chordpress') . "<br> 756 884 <div class='cpress-btn-group' role='group'> 757 885 <button type='button' class='cpress-btn cpress-btn-secondary cpress-btn-sm' onclick=\"transposeChords('%cpressID%', 'btnTranspose-', 'down', " . $songKey . ");\">-</button> … … 759 887 <button type='button' class='cpress-btn cpress-btn-secondary cpress-btn-sm' onclick=\"transposeChords('%cpressID%', 'btnTranspose-', 'up', " . $songKey . ");\">+</button> 760 888 </div>"; 889 } else { 890 // 891 // Let's see if a 'Key' directive was given. If so, we can add the transposed keys to the list. 892 // 893 if (strlen($this->arrDirectives['key']) && in_array($this->arrDirectives['key'], $this->arrKeys)) { 894 $i = 0; 895 foreach ($this->arrTransposeValues[$this->arrDirectives['key']] as $val) { 896 $tvalues[] = (string)$i . ' => ' . $val; 897 $i++; 898 } 761 899 } else { 762 // 763 // Let's see if a 'Key' directive was given. If so, we can add the transposed keys to the list. 764 // 765 if (strlen($this->arrDirectives['key']) && in_array($this->arrDirectives['key'], $this->arrKeys)) { 766 $i = 0; 767 foreach ($this->arrTransposeValues[$this->arrDirectives['key']] as $val) { 768 $tvalues[] = (string)$i . ' => ' . $val; 769 $i++; 770 } 771 } else { 772 $tvalues = array( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11' ); 773 } 774 $interactionForm .= __('Transpose', 'chordpress') . " 900 $tvalues = array( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11' ); 901 } 902 $interactionForm .= __('Transpose', 'chordpress') . " 775 903 <div class=\"float-right\"> 776 904 <select class=\"cpress-form-control cpress-form-control-sm cpress-py-0 cpress-px-2\" id=\"selTranspose-%cpressID%\" onchange=\"transposeChords('%cpressID%', 'selTranspose-');return false;\" title=\"" . __('Only works for international key names', 'chordpress') . ".\"> … … 789 917 </select> 790 918 </div>"; 791 }792 } else {793 //794 // Harmonica notes795 //796 switch ($this->harmonica) {797 case 'tremolo':798 $selectedDiatonic = '';799 $selectedChromatic = '';800 $selectedTremolo = ' selected';801 break;802 case 'diatonic':803 $selectedDiatonic = ' selected';804 $selectedChromatic = '';805 $selectedTremolo = '';806 break;807 case 'chromatic':808 $selectedDiatonic = '';809 $selectedChromatic = ' selected';810 $selectedTremolo = '';811 break;812 default:813 $selectedDiatonic = '';814 $selectedChromatic = '';815 $selectedTremolo = '';816 break;817 }818 819 $interactionForm .=820 "<div class='cpress-row'>919 } 920 } else { 921 // 922 // Harmonica notes 923 // 924 switch ($this->harmonica) { 925 case 'tremolo': 926 $selectedDiatonic = ''; 927 $selectedChromatic = ''; 928 $selectedTremolo = ' selected'; 929 break; 930 case 'diatonic': 931 $selectedDiatonic = ' selected'; 932 $selectedChromatic = ''; 933 $selectedTremolo = ''; 934 break; 935 case 'chromatic': 936 $selectedDiatonic = ''; 937 $selectedChromatic = ' selected'; 938 $selectedTremolo = ''; 939 break; 940 default: 941 $selectedDiatonic = ''; 942 $selectedChromatic = ''; 943 $selectedTremolo = ''; 944 break; 945 } 946 947 $interactionForm .= 948 "<div class='cpress-row'> 821 949 <div class='cpress-col'>"; 822 950 823 $interactionForm .= __('Harmonica', 'chordpress') . "<br>951 $interactionForm .= __('Harmonica', 'chordpress') . "<br> 824 952 <select 825 953 class=\"cpress-form-control cpress-form-control-sm cpress-py-0 cpress-px-2\" … … 834 962 </select>"; 835 963 836 $interactionForm .= "964 $interactionForm .= " 837 965 </div> 838 966 <div class='cpress-col'>"; 839 967 840 if ($this->harmonica == 'chromatic') {841 $baseNote = "''";842 $initialText = '0';843 $interactionForm .= "<span id='btnTranspose-chromatic'>" . __('Transpose', 'chordpress') . "<br>968 if ($this->harmonica == 'chromatic') { 969 $baseNote = "''"; 970 $initialText = '0'; 971 $interactionForm .= "<span id='btnTranspose-chromatic'>" . __('Transpose', 'chordpress') . "<br> 844 972 <div class='cpress-btn-group' role='group'> 845 973 <button type='button' class='cpress-btn cpress-btn-secondary cpress-btn-sm' onclick=\"transposeChromatic('%cpressID%', 'btnTranspose-', 'down', " . $baseNote . ");\">-</button> … … 848 976 </div> 849 977 </span>"; 850 }851 $interactionForm .= "978 } 979 $interactionForm .= " 852 980 </div> 853 981 </div>"; 854 }855 $interactionForm .= "</div>";856 }857 $interactionForm .= "<div class='cpress-col cpress-pr-0'>";858 if (!$this->hidePrint) {859 $printTitle = 'ChordPress SongSheet';860 if (strlen($this->arrDirectives['title']) && !$this->hideTitle) {861 $printTitle = $this->arrDirectives['title'];862 }863 $interactionForm .= "<br><button class='cpress-btn cpress-btn-secondary cpress-btn-sm' onclick=\"printElement('%cpressID%', '" . $printTitle . "', '" . $cpressStyles . "');\">" . __('Print', 'chordpress') . "</button>\n";864 // $interactionForm .= "<br><button class='cpress-btn cpress-btn-secondary cpress-btn-sm' onclick=\"window.print();\">" . __('Print', 'chordpress') . "</button>\n";865 982 } 866 983 $interactionForm .= "</div>"; 867 $returnText .= $interactionForm . "</div>\n"; 868 } 869 870 $returnText .= "<div id=\"%cpressID%\" class=\"cpress\">\n"; 871 872 /** 873 * Print header if directives exist 874 */ 875 $randId = $this->random_string(true); 876 if (strlen($this->arrDirectives['title']) && !$this->hideTitle) { 877 $cpressID = str_replace(' ', '-', strtolower(trim($this->arrDirectives['title']))) . '-' . $randId; 878 $returnText = str_replace('%cpressID%', $cpressID, $returnText); 879 $returnText .= '<' . $this->titleLevel . '>' . $this->arrDirectives['title'] . '</' . $this->titleLevel . ">\n"; 880 } else { 881 $cpressID = 'ccpress-id-' . $randId; 882 $returnText = str_replace('%cpressID%', $cpressID, $returnText); 883 } 884 885 if (strlen($this->arrDirectives['subtitle']) && !$this->hideSubtitle) { 886 $returnText .= '<' . $this->subtitleLevel . '>' . $this->arrDirectives['subtitle'] . '</' . $this->subtitleLevel . ">\n"; 887 } 888 889 if ( 890 strlen($this->arrDirectives['album']) || 891 strlen($this->arrDirectives['artist']) || 892 strlen($this->arrDirectives['capo']) || 893 strlen($this->arrDirectives['composer']) || 894 strlen($this->arrDirectives['key']) || 895 strlen($this->arrDirectives['tempo']) || 896 strlen($this->arrDirectives['time']) || 897 strlen($this->arrDirectives['year']) 898 ) { 899 $returnText .= "<div class=\"cpress_meta\">\n"; 900 if (strlen($this->arrDirectives['composer']) && !$this->hideComposer) $returnText .= esc_html(__('Composer', 'chordpress')) . ': ' . $this->arrDirectives['composer'] . "<br>\n"; 901 if (strlen($this->arrDirectives['artist']) && !$this->hideArtist) $returnText .= esc_html(__('Artist', 'chordpress')) . ': ' . $this->arrDirectives['artist'] . "<br>\n"; 902 if (strlen($this->arrDirectives['year']) && !$this->hideYear) $returnText .= esc_html(__('Year', 'chordpress')) . ': ' . $this->arrDirectives['year'] . "<br>\n"; 903 if (strlen($this->arrDirectives['album']) && !$this->hideAlbum) $returnText .= esc_html(__('Album', 'chordpress')) . ': ' . $this->arrDirectives['album'] . "<br>\n"; 904 905 if (strlen($this->arrDirectives['key']) && !$this->hideKey) { 906 $returnText .= esc_html(__('Key (original)', 'chordpress')) . ': ' . $this->arrDirectives['key'] . "<br>\n"; 907 $returnText .= esc_html(__('Key (transposed)', 'chordpress')) . ': <span class="chord-hidable-%cpressID% key-%cpressID%-0">' . $this->arrDirectives['key'] . '</span>'; 908 for ($t = 1; $t <= 11; $t++) { 909 $returnText .= '<span class="chord-hidable-%cpressID% key-%cpressID%-' . $t . '" style="display:none">' . $this->arrTransposeValues[$this->arrDirectives['key']][$t] . '</span>'; 910 } 911 $returnText .= "<br>\n"; 984 } 985 $interactionForm .= "<div class='cpress-col cpress-pr-0'>"; 986 if (!$this->hidePrint) { 987 $printTitle = 'ChordPress SongSheet'; 988 if (strlen($this->arrDirectives['title']) && !$this->hideTitle) { 989 $printTitle = $this->arrDirectives['title']; 912 990 } 913 914 if (strlen($this->arrDirectives['time'])) $returnText .= esc_html(__('Time', 'chordpress')) . ': ' . $this->arrDirectives['time'] . "<br>\n"; 915 if (strlen($this->arrDirectives['tempo'])) $returnText .= esc_html(__('Tempo', 'chordpress')) . ': ' . $this->arrDirectives['tempo'] . "<br>\n"; 916 if (strlen($this->arrDirectives['capo'])) $returnText .= esc_html(__('Capo', 'chordpress')) . ': ' . $this->arrDirectives['capo'] . "<br>\n"; 917 $returnText = preg_replace('/<br>$/', '', $returnText); // Remove last <br> 918 $returnText .= "</div>\n"; 919 } 920 921 /** 922 * Go through each line and process it 923 */ 924 $this->inMonospace = false; 925 foreach ($text as $line) { 926 if ($this->inMonospace && strpos($line, "{end_of_monospace}") === false) { 927 $returnText .= $line; 928 } else { 929 $returnText .= $this->formatAndDisplayLine($line); 930 } 931 } 932 $returnText = str_replace('%cpressID%', $cpressID, $returnText); 933 934 /** 935 * End of ChordPress song 936 */ 937 $returnText .= "</div>\n<!--end: ChordPress SongSheet-->\n"; 938 939 /** 940 * Build chord sheet if option set to true. 941 */ 942 if ($this->showChordSheet) { 943 $chordSheetText = "\n<!--begin: ChordPress ChordSheet-->\n"; 944 $chordSheetText .= "<div class='cpress_chordsheet'>\n"; 945 $chordSheetText .= "<div><hr></div>\n"; 946 $chordSheetText .= "<p><i>" . esc_html(__('These known chords are used in this song', 'chordpress')) . ".</i></p>"; 947 $this->uniqueChords = array_unique($this->allChords); 948 foreach ($this->uniqueChords as $uc) { 949 if ($postid = $this->find_guitar_chord_post($uc)) { 950 $this->load_guitar_chord($postid); 951 $chordSheetText .= $this->C->createSvgChord(true); 952 } 953 } 954 $chordSheetText .= "</div>\n<div style=\"clear:both; padding: 16px 0 16px 0;\"><hr></div>\n<!--end: ChordPress ChordSheet-->\n\n"; 955 if ($this->showChordSheetOnTop) { 956 $returnText = $chordSheetText . $returnText; 957 } else { 958 $returnText = $returnText . $chordSheetText; 959 } 960 } 961 962 // $this->C->dnd($returnText); 963 return $returnText . "\n\n"; 991 $interactionForm .= "<br><button class='cpress-btn cpress-btn-secondary cpress-btn-sm' onclick=\"printElement('%cpressID%', '" . $printTitle . "', '" . $this->songsheetStyles . "');\">" . __('Print', 'chordpress') . "</button>\n"; 992 } 993 $interactionForm .= "</div>"; 994 return $interactionForm; 964 995 } 965 996 … … 976 1007 * @since 1.0.0 977 1008 */ 978 public function formatAndDisplayLine( $line){1009 public function formatAndDisplayLine(string $line): string { 979 1010 $returnText = ""; 980 1011 … … 1261 1292 * @since 1.0.0 1262 1293 */ 1263 private function stripTags( $string){1294 private function stripTags(string $string): string { 1264 1295 $retString = ""; 1265 1296 $isVisible = true; … … 1289 1320 * @since 1.0.0 1290 1321 */ 1291 public function formatChord( $ch){1322 public function formatChord(string $ch): string { 1292 1323 $useFlats = false; 1293 1324 if (strlen($ch) == 0) return ''; … … 1352 1383 * Processes a Chromatic harmonica note and returns the formatted HTML. 1353 1384 * 1354 * @param string $note - Chromatic note, e.g. "1" or "1s" or "-1" or "-1s". 1385 * @param string $note - Chromatic note, e.g. "1" or "1s" or "-1" or "-1s". 1386 * @param int $transpose - Numeric transpose value, 0-11. 1355 1387 * 1356 1388 * @return string - Transposed chromatic note 1357 1389 * @since 2.8.0 1358 1390 */ 1359 public function transposeChromaticNote( $note, $transpose){1391 public function transposeChromaticNote(string $note, int $transpose): string { 1360 1392 if (strlen($note) == 0) return ''; 1361 1393 if ($transpose === 0 || $transpose > 11) return $note; … … 1396 1428 * @since 1.0.0 1397 1429 */ 1398 public function formatRemainder( $remainder){1430 public function formatRemainder(string $remainder): string { 1399 1431 $indexOfSlash = strpos($remainder, '/'); 1400 1432 if ($indexOfSlash === false) return $remainder; … … 1465 1497 * @since 1.0.0 1466 1498 */ 1467 public function noteToNumber( $n){1499 public function noteToNumber(string $n): int { 1468 1500 $regularNotation = array( 1469 1501 'A' => 0, … … 1515 1547 * @since 1.0.0 1516 1548 */ 1517 public function numberToNote( $n, $useFlats = false){1549 public function numberToNote(string $n, bool $useFlats = false): string { 1518 1550 $retVal = ''; 1519 1551 … … 1586 1618 * @since 3.8.0 1587 1619 */ 1588 public function translateHarmonicaNote( $note, $from, $to){1620 public function translateHarmonicaNote(string $note, string $from, string $to): string { 1589 1621 1590 1622 $from = strtolower($from); … … 1687 1719 * @since 1.0.0 1688 1720 */ 1689 public function getDisplayHBNotation() {1721 public function getDisplayHBNotation(): bool { 1690 1722 return $this->displayHBNotation; 1691 1723 } … … 1702 1734 * @since 1.0.0 1703 1735 */ 1704 public function setDisplayHBNotation( $g){1736 public function setDisplayHBNotation(bool $g): void { 1705 1737 $this->displayHBNotation = $g; 1706 1738 } … … 1716 1748 * @since 1.0.0 1717 1749 */ 1718 public function getFloat() {1750 public function getFloat(): string { 1719 1751 return $this->float; 1720 1752 } … … 1731 1763 * @since 1.0.0 1732 1764 */ 1733 public function setFloat( $f){1765 public function setFloat(string $f): void { 1734 1766 $this->float = $f; 1735 1767 } … … 1745 1777 * @since 3.8.0 1746 1778 */ 1747 public function getHarmonica() {1779 public function getHarmonica(): string { 1748 1780 return $this->harmonica; 1749 1781 } … … 1760 1792 * @since 3.8.0 1761 1793 */ 1762 public function setHarmonica( $h){1794 public function setHarmonica(string $h): void { 1763 1795 if (in_array(strtolower($h), $this->harmonicaTypes)) { 1764 1796 $this->harmonica = strtolower($h); … … 1778 1810 * @since 1.0.0 1779 1811 */ 1780 public function getHBNotation() {1812 public function getHBNotation(): string { 1781 1813 return $this->hbNotation; 1782 1814 } … … 1793 1825 * @since 1.0.0 1794 1826 */ 1795 public function setHBNotation( $g){1827 public function setHBNotation(string $g): void { 1796 1828 $this->hbNotation = $g; 1797 1829 } … … 1807 1839 * @since 3.5.0 1808 1840 */ 1809 public function getHideChords() {1841 public function getHideChords(): string { 1810 1842 return $this->hideChords; 1811 1843 } … … 1822 1854 * @since 3.5.0 1823 1855 */ 1824 public function setHideChords( $g){1856 public function setHideChords(string $g): void { 1825 1857 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 1826 1858 $this->hideChords = true; … … 1840 1872 * @since 3.5.0 1841 1873 */ 1842 public function getHideComments() {1874 public function getHideComments(): string { 1843 1875 return $this->hideComments; 1844 1876 } … … 1855 1887 * @since 3.5.0 1856 1888 */ 1857 public function setHideComments( $g){1889 public function setHideComments(string $g): void { 1858 1890 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 1859 1891 $this->hideComments = 1; … … 1873 1905 * @since 3.5.0 1874 1906 */ 1875 public function getHideComposer() {1907 public function getHideComposer(): string { 1876 1908 return $this->hideComposer; 1877 1909 } … … 1888 1920 * @since 3.5.0 1889 1921 */ 1890 public function setHideComposer( $g){1922 public function setHideComposer(string $g): void { 1891 1923 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 1892 1924 $this->hideComposer = 1; … … 1906 1938 * @since 3.5.0 1907 1939 */ 1908 public function getHidePrint() {1940 public function getHidePrint(): string { 1909 1941 return $this->hidePrint; 1910 1942 } … … 1921 1953 * @since 3.5.0 1922 1954 */ 1923 public function setHidePrint( $g){1955 public function setHidePrint(string $g): void { 1924 1956 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 1925 1957 $this->hidePrint = 1; … … 1939 1971 * @since 3.5.0 1940 1972 */ 1941 public function getHideSubtitle() {1973 public function getHideSubtitle(): string { 1942 1974 return $this->hideSubtitle; 1943 1975 } … … 1954 1986 * @since 3.5.0 1955 1987 */ 1956 public function setHideSubtitle( $g){1988 public function setHideSubtitle(string $g): void { 1957 1989 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 1958 1990 $this->hideSubtitle = 1; … … 1972 2004 * @since 3.5.0 1973 2005 */ 1974 public function getHideTitle() {2006 public function getHideTitle(): string { 1975 2007 return $this->hideTitle; 1976 2008 } … … 1987 2019 * @since 3.5.0 1988 2020 */ 1989 public function setHideTitle( $g){2021 public function setHideTitle(string $g): void { 1990 2022 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 1991 2023 $this->hideTitle = 1; … … 2005 2037 * @since 3.8.1 2006 2038 */ 2007 public function getFontsize() {2039 public function getFontsize(): string { 2008 2040 return $this->hideFontsize; 2009 2041 } … … 2020 2052 * @since 3.8.1 2021 2053 */ 2022 public function setHideFontsize( $g){2054 public function setHideFontsize(string $g): void { 2023 2055 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 2024 2056 $this->hideFontsize = 1; … … 2038 2070 * @since 3.5.0 2039 2071 */ 2040 public function getHideTranspose() {2072 public function getHideTranspose(): string { 2041 2073 return $this->hideTranspose; 2042 2074 } … … 2053 2085 * @since 3.5.0 2054 2086 */ 2055 public function setHideTranspose( $g){2087 public function setHideTranspose(string $g): void { 2056 2088 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 2057 2089 $this->hideTranspose = 1; … … 2071 2103 * @since 3.6.0 2072 2104 */ 2073 public function getNumericTranspose() {2105 public function getNumericTranspose(): string { 2074 2106 return $this->showNumericTranspose; 2075 2107 } … … 2086 2118 * @since 3.6.0 2087 2119 */ 2088 public function setNumericTranspose( $g){2120 public function setNumericTranspose(string $g): void { 2089 2121 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 2090 2122 $this->showNumericTranspose = 1; … … 2104 2136 * @since 3.6.0 2105 2137 */ 2106 public function getFixedInteraction() {2138 public function getFixedInteraction(): string { 2107 2139 return $this->fixedInteraction; 2108 2140 } … … 2119 2151 * @since 3.6.0 2120 2152 */ 2121 public function setFixedInteraction( $g){2153 public function setFixedInteraction(string $g): void { 2122 2154 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 2123 2155 $this->fixedInteraction = 1; … … 2137 2169 * @since 3.5.0 2138 2170 */ 2139 public function getHideYear() {2171 public function getHideYear(): string { 2140 2172 return $this->hideYear; 2141 2173 } … … 2152 2184 * @since 3.5.0 2153 2185 */ 2154 public function setHideYear( $g){2186 public function setHideYear(string $g): void { 2155 2187 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 2156 2188 $this->hideYear = 1; … … 2170 2202 * @since 1.0.0 2171 2203 */ 2172 public function getInteractive() {2204 public function getInteractive(): string { 2173 2205 return $this->interactive; 2174 2206 } … … 2185 2217 * @since 1.0.0 2186 2218 */ 2187 public function setInteractive( $i){2219 public function setInteractive(string $i): void { 2188 2220 $this->interactive = $i; 2189 2221 } … … 2199 2231 * @since 3.5.0 2200 2232 */ 2201 public function getShowChordSheet() {2233 public function getShowChordSheet(): string { 2202 2234 return $this->showChordSheet; 2203 2235 } … … 2214 2246 * @since 3.5.0 2215 2247 */ 2216 public function setShowChordSheet( $g){2248 public function setShowChordSheet(string $g): void { 2217 2249 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 2218 2250 $this->showChordSheet = 1; … … 2232 2264 * @since 3.5.0 2233 2265 */ 2234 public function getShowChordSheetOnTop() {2266 public function getShowChordSheetOnTop(): string { 2235 2267 return $this->showChordSheetOnTop; 2236 2268 } … … 2247 2279 * @since 3.5.0 2248 2280 */ 2249 public function setShowChordSheetOnTop( $g){2281 public function setShowChordSheetOnTop(string $g): void { 2250 2282 if (in_array(strtolower($g), array( "yes", "1", "true" ))) { 2251 2283 $this->showChordSheetOnTop = 1; … … 2265 2297 * @since 1.0.0 2266 2298 */ 2267 public function getTranspose() {2299 public function getTranspose(): int { 2268 2300 return $this->transpose; 2269 2301 } … … 2280 2312 * @since 1.0.0 2281 2313 */ 2282 public function setTranspose( $t){2314 public function setTranspose(int $t): void { 2283 2315 $this->transpose = $t; 2284 2316 } … … 2295 2327 * @return integer - Post ID or NULL 2296 2328 */ 2297 private function find_guitar_chord_post( $shortname){2329 private function find_guitar_chord_post(string $shortname): int { 2298 2330 $query_args = array( 2299 2331 'posts_per_page' => 1, … … 2322 2354 * @return void 2323 2355 */ 2324 private function load_guitar_chord( $postid){2356 private function load_guitar_chord(int $postid): void { 2325 2357 $my_chord = array(); 2326 2358 $post = get_post($postid); … … 2361 2393 * @return string - Modal chord dialog HTML 2362 2394 */ 2363 // private function create_modal_chord($postid, $chord) 2364 // { 2395 // private function create_modal_chord(int $postid, string $chord): string { 2365 2396 // $modal_chord = '<!-- <button id="cpress-chord-' . $postid . '-modal-button">Click here to trigger the modal!</button> --> 2366 2397 // <div id="cpress-chord-' . $postid . '-modal" class="cpress-modal"> … … 2405 2436 * @return false|string 2406 2437 */ 2407 private function random_string( $alphaonly = false, $length = 15){2438 private function random_string(bool $alphaonly = false, int $length = 15): string|false { 2408 2439 if ($alphaonly) { 2409 2440 return substr(str_shuffle(str_repeat($x = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length); … … 2424 2455 * @since 3.2.0 2425 2456 */ 2426 private function dnd( $a, $die = true){2457 private function dnd(array $a, bool $die = true): string { 2427 2458 $dump = highlight_string("<?php\n\$data =\n" . var_export($a, true) . ";\n?>"); 2428 if ($die) die($dump); 2429 else return $dump; 2459 if ($die) { 2460 die($dump); 2461 } else { 2462 return $dump; 2463 } 2430 2464 } 2431 2465 } -
chordpress/trunk/languages/chordpress.pot
r3298894 r3307608 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Lewe ChordPress 3.9. 0\n"5 "Project-Id-Version: Lewe ChordPress 3.9.2\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/chordpress\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 2025-0 5-22T18:00:03+02:00\n"12 "POT-Creation-Date: 2025-06-06T19:11:35+02:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 14 "X-Generator: WP-CLI 2.4.0\n" … … 550 550 551 551 #: admin/partials/chordpress-admin-options.php:394 552 msgid "With this option selected, the interaction menu will be fixed at the bottom of the page. Note, that this might lead to unexpected results depending on the WordPress theme you use . You can overwrite this setting per shortcut with \"fixedinteraction=yes/no\""552 msgid "With this option selected, the interaction menu will be fixed at the bottom of the page. Note, that this might lead to unexpected results depending on the WordPress theme you use and if you use more than one ChordPress songsheet on a page. You can overwrite this setting per shortcut with \"fixedinteraction=yes/no\"" 553 553 msgstr "" 554 554 … … 1248 1248 msgstr "" 1249 1249 1250 #: includes/class-chordpress-renderer.php:740 1251 msgid "Font" 1252 msgstr "" 1253 1254 #: includes/class-chordpress-renderer.php:767 1255 #: includes/class-chordpress-renderer.php:786 1250 #: includes/class-chordpress-renderer.php:763 1251 msgid "Composer" 1252 msgstr "" 1253 1254 #: includes/class-chordpress-renderer.php:764 1255 msgid "Artist" 1256 msgstr "" 1257 1258 #: includes/class-chordpress-renderer.php:765 1259 msgid "Year" 1260 msgstr "" 1261 1262 #: includes/class-chordpress-renderer.php:766 1263 msgid "Album" 1264 msgstr "" 1265 1266 #: includes/class-chordpress-renderer.php:769 1267 msgid "Key (original)" 1268 msgstr "" 1269 1270 #: includes/class-chordpress-renderer.php:770 1271 msgid "Key (transposed)" 1272 msgstr "" 1273 1274 #: includes/class-chordpress-renderer.php:777 1275 msgid "Time" 1276 msgstr "" 1277 1278 #: includes/class-chordpress-renderer.php:778 1279 msgid "Tempo" 1280 msgstr "" 1281 1282 #: includes/class-chordpress-renderer.php:779 1283 msgid "Capo" 1284 msgstr "" 1285 1286 #: includes/class-chordpress-renderer.php:809 1287 msgid "These known chords are used in this song" 1288 msgstr "" 1289 1256 1290 #: includes/class-chordpress-renderer.php:854 1291 msgid "Font Size" 1292 msgstr "" 1293 1294 #: includes/class-chordpress-renderer.php:881 1295 #: includes/class-chordpress-renderer.php:900 1296 #: includes/class-chordpress-renderer.php:969 1257 1297 msgid "Transpose" 1258 1298 msgstr "" 1259 1299 1260 #: includes/class-chordpress-renderer.php: 7881300 #: includes/class-chordpress-renderer.php:902 1261 1301 msgid "Only works for international key names" 1262 1302 msgstr "" 1263 1303 1264 #: includes/class-chordpress-renderer.php: 8351304 #: includes/class-chordpress-renderer.php:949 1265 1305 msgid "Harmonica" 1266 1306 msgstr "" 1267 1307 1268 #: includes/class-chordpress-renderer.php: 8401308 #: includes/class-chordpress-renderer.php:955 1269 1309 msgid "Only works when using harmonica notation" 1270 1310 msgstr "" 1271 1311 1272 #: includes/class-chordpress-renderer.php: 8421312 #: includes/class-chordpress-renderer.php:957 1273 1313 msgid "Diatonic" 1274 1314 msgstr "" 1275 1315 1276 #: includes/class-chordpress-renderer.php: 8431316 #: includes/class-chordpress-renderer.php:958 1277 1317 msgid "Chromatic" 1278 1318 msgstr "" 1279 1319 1280 #: includes/class-chordpress-renderer.php: 8441320 #: includes/class-chordpress-renderer.php:959 1281 1321 msgid "Tremolo" 1282 1322 msgstr "" 1283 1323 1284 #: includes/class-chordpress-renderer.php: 8701324 #: includes/class-chordpress-renderer.php:989 1285 1325 msgid "Print" 1286 1326 msgstr "" 1287 1327 1288 #: includes/class-chordpress-renderer.php:906 1289 msgid "Composer" 1290 msgstr "" 1291 1292 #: includes/class-chordpress-renderer.php:907 1293 msgid "Artist" 1294 msgstr "" 1295 1296 #: includes/class-chordpress-renderer.php:908 1297 msgid "Year" 1298 msgstr "" 1299 1300 #: includes/class-chordpress-renderer.php:909 1301 msgid "Album" 1302 msgstr "" 1303 1304 #: includes/class-chordpress-renderer.php:912 1305 msgid "Key (original)" 1306 msgstr "" 1307 1308 #: includes/class-chordpress-renderer.php:913 1309 msgid "Key (transposed)" 1310 msgstr "" 1311 1312 #: includes/class-chordpress-renderer.php:920 1313 msgid "Time" 1314 msgstr "" 1315 1316 #: includes/class-chordpress-renderer.php:921 1317 msgid "Tempo" 1318 msgstr "" 1319 1320 #: includes/class-chordpress-renderer.php:922 1321 msgid "Capo" 1322 msgstr "" 1323 1324 #: includes/class-chordpress-renderer.php:952 1325 msgid "These known chords are used in this song" 1326 msgstr "" 1327 1328 #: includes/class-chordpress-renderer.php:1070 1328 #: includes/class-chordpress-renderer.php:1093 1329 1329 msgid "Missing square bracket in line" 1330 1330 msgstr "" -
chordpress/trunk/readme.txt
r3307598 r3307608 5 5 Requires at least: 4.0 6 6 Tested up to: 6.8 7 Stable tag: 3.9. 27 Stable tag: 3.9.3 8 8 Requires PHP: 5.2.4 9 9 License: GPLv3 … … 130 130 131 131 == Changelog == 132 = 3.9.3 = 133 * 2025-06-06 134 * Improved interaction menu (but do not use fixed position when more than one song on a page) 135 132 136 = 3.9.2 = 133 137 * 2025-06-02
Note: See TracChangeset
for help on using the changeset viewer.