| @@ -18,8 +18,31 @@ | ||
| 18 | 18 | return is_null($key) ? $api : $api->{$key}; |
| 19 | 19 | } |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | +if (!function_exists('fluent_boards_sanitize_description')) { | |
| 23 | + function fluent_boards_sanitize_description($description): string | |
| 24 | + { | |
| 25 | + $description = preg_replace_callback('/<((?:https?:\/\/)[^<>\s]+)>/i', function ($matches) { | |
| 26 | + $url = esc_url_raw(html_entity_decode($matches[1], ENT_QUOTES | ENT_HTML5, 'UTF-8')); | |
| 27 | + | |
| 28 | + return $url ? '[' . $url . '](' . str_replace(')', '%29', $url) . ')' : $matches[0]; | |
| 29 | + }, (string) $description); | |
| 30 | + | |
| 31 | + // KSES encodes standalone > characters, which breaks Markdown quotes. | |
| 32 | + // Protect only quote prefixes; all HTML still passes through KSES. | |
| 33 | + $quotePrefix = 'fbs-quote-' . wp_generate_uuid4() . '-'; | |
| 34 | + $quotes = []; | |
| 35 | + $description = preg_replace_callback('/^[ \t]*(?:>[ \t]*)+/m', function ($matches) use (&$quotes, $quotePrefix) { | |
| 36 | + $key = $quotePrefix . count($quotes); | |
| 37 | + $quotes[$key] = $matches[0]; | |
| 38 | + return $key; | |
| 39 | + }, $description); | |
| 40 | + | |
| 41 | + return strtr(wp_kses_post($description), $quotes); | |
| 42 | + } | |
| 43 | +} | |
| 44 | + | |
| 22 | 45 | if (!function_exists('fluent_boards_user_avatar')) { |
| 23 | 46 | function fluent_boards_user_avatar($email, $name = '') |
| 24 | 47 | { |
| 25 | 48 | $user = get_user_by('email', $email); |
| @@ -79,8 +102,20 @@ | ||
| 79 | 102 | if (!function_exists('fluent_boards_page_url')) { |
| 80 | 103 | function fluent_boards_page_url(): ?string |
| 81 | 104 | { |
| 82 | 105 | return apply_filters('fluent_boards/app_url', admin_url('admin.php?page=fluent-boards#/')); |
| 106 | + } | |
| 107 | +} | |
| 108 | + | |
| 109 | +if (!function_exists('fluent_boards_is_rtl')) { | |
| 110 | + /** | |
| 111 | + * Determine if Fluent Boards should render right-to-left UI. | |
| 112 | + * | |
| 113 | + * @return bool | |
| 114 | + */ | |
| 115 | + function fluent_boards_is_rtl(): bool | |
| 116 | + { | |
| 117 | + return is_rtl(); | |
| 83 | 118 | } |
| 84 | 119 | } |
| 85 | 120 | |
| 86 | 121 | function fluent_boards_get_pref_settings($cached = true) |