| @@ -65,15 +65,15 @@ | ||
| 65 | 65 | |
| 66 | 66 | $settings = (array) $space->getCustomMeta('lockscreen_settings', $defaultSettings); |
| 67 | 67 | |
| 68 | 68 | foreach ($settings as &$setting) { |
| 69 | - if ($viewOnly && $setting['type'] === 'block' && !empty($setting['content'])) { | |
| 69 | + if ($viewOnly && Arr::get($setting, 'type') === 'block' && !empty($setting['content'])) { | |
| 70 | 70 | $user = Helper::getCurrentUser(); |
| 71 | - $content = apply_filters('the_content', $setting['content']); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound | |
| 71 | + $content = self::renderBlockContent($setting['content']); | |
| 72 | 72 | $setting['content'] = (new SmartCodeParser())->parse($content, $user); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if ($setting['type'] == 'image' && empty($setting['new_tab'])) { | |
| 75 | + if (Arr::get($setting, 'type') == 'image' && empty($setting['new_tab'])) { | |
| 76 | 76 | $setting['new_tab'] = 'no'; |
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
| @@ -79,8 +79,26 @@ | ||
| 79 | 79 | |
| 80 | 80 | return apply_filters('fluent_community/lockscreen_fields', $settings, $space); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | + /** | |
| 84 | + * Renders without the_content: a space admin need not hold unfiltered_html, and | |
| 85 | + * the_content's do_shortcode pass would run their shortcodes for every visitor. | |
| 86 | + */ | |
| 87 | + protected static function renderBlockContent($content) | |
| 88 | + { | |
| 89 | + $rendered = do_blocks(strip_shortcodes($content)); | |
| 90 | + | |
| 91 | + // Core skips wpautop for block content to avoid mangling it. | |
| 92 | + if (!has_blocks($content)) { | |
| 93 | + $rendered = wpautop($rendered); | |
| 94 | + } | |
| 95 | + | |
| 96 | + $rendered = wptexturize($rendered); | |
| 97 | + | |
| 98 | + return wp_filter_content_tags($rendered); | |
| 99 | + } | |
| 100 | + | |
| 83 | 101 | public static function formatLockscreenFields($settingFields, $space) |
| 84 | 102 | { |
| 85 | 103 | $currentSettings = self::getLockscreenSettings($space); |
| 86 | 104 | |
| @@ -96,9 +114,9 @@ | ||
| 96 | 114 | $formattedField = array_merge($textValues, $urlValues); |
| 97 | 115 | |
| 98 | 116 | $formattedField['hidden'] = Arr::isTrue($value, 'hidden'); |
| 99 | 117 | |
| 100 | - if ($value['type'] == 'block') { | |
| 118 | + if (Arr::get($value, 'type') == 'block') { | |
| 101 | 119 | $formattedField['content'] = CustomSanitizer::santizeEditorBody(Arr::get($value, 'content')); |
| 102 | 120 | } |
| 103 | 121 | |
| 104 | 122 | if (isset($value['background_image'])) { |