← All changes
|
includes/widgets/Creative_Button/Creative_Button.php
+17
-3
51.1.35
→
51.1.83
View file →
| @@ -783,9 +783,9 @@ | ||
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | protected function render(): void |
| 786 | 786 | { |
| 787 | - $settings = $this->get_settings(); | |
| 787 | + $settings = Core::displaySettings($this); | |
| 788 | 788 | |
| 789 | 789 | switch ($settings['king_addons_creative_btn_style']) { |
| 790 | 790 | case 'london': |
| 791 | 791 | $this->renderLondon($settings, $this->get_id()); |
| @@ -884,13 +884,19 @@ | ||
| 884 | 884 | echo ' data-text="' . esc_attr($settings['king_addons_creative_btn_button_text']) . '"'; |
| 885 | 885 | } |
| 886 | 886 | echo '>'; |
| 887 | 887 | |
| 888 | - $btn_txt = esc_html($settings['king_addons_creative_btn_button_text']); | |
| 888 | + // The label is kept raw here and escaped once, where it goes into | |
| 889 | + // markup. Escaping it up front and again below turned "Tom & Jerry" | |
| 890 | + // into visible "Tom & Jerry" in the apex effect, because splitText() | |
| 891 | + // cuts the entity apart and wp_kses can no longer recognise it. | |
| 892 | + $btn_txt = $settings['king_addons_creative_btn_button_text']; | |
| 889 | 893 | if ('serene' == $effect || 'zephyr' == $effect || 'brilliance' == $effect) { |
| 890 | 894 | $btn_txt = '<span>' . esc_html($btn_txt) . '</span>'; |
| 891 | 895 | } elseif ('apex' == $effect) { |
| 892 | 896 | $btn_txt = $this->splitText($btn_txt); |
| 897 | + } else { | |
| 898 | + $btn_txt = esc_html($btn_txt); | |
| 893 | 899 | } |
| 894 | 900 | |
| 895 | 901 | // Define allowed tags and attributes |
| 896 | 902 | $allowed_tags = wp_kses_allowed_html('post'); |
| @@ -966,9 +972,17 @@ | ||
| 966 | 972 | public function splitText($text): string |
| 967 | 973 | { |
| 968 | 974 | $base = 0.045; |
| 969 | 975 | $markup = ''; |
| 970 | - foreach (str_split($text) as $key => $value) { | |
| 976 | + | |
| 977 | + // str_split() cuts bytes, not characters: a Cyrillic label came out as | |
| 978 | + // twice as many empty spans, because every half of a character was | |
| 979 | + // invalid UTF-8 and esc_html() dropped it. The button rendered blank. | |
| 980 | + $characters = function_exists('mb_str_split') | |
| 981 | + ? mb_str_split((string) $text) | |
| 982 | + : preg_split('//u', (string) $text, -1, PREG_SPLIT_NO_EMPTY); | |
| 983 | + | |
| 984 | + foreach ((array) $characters as $key => $value) { | |
| 971 | 985 | $delay = $base * ($key + 1); |
| 972 | 986 | $markup .= trim($value) ? '<span style="--king-addons-creative-btn-effect-apex-delay:' . esc_attr($delay) . 's">' . esc_html($value) . '</span>' : '<span> </span>'; |
| 973 | 987 | } |
| 974 | 988 | return $markup; |