PluginProbe
Extendify / trunk
Extendify vtrunk
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
← All changes | app/QuickEdit/Schemas/MediaText.php +18 -15 3.1.2 → trunk View file →
@@ -87,9 +87,11 @@
87 87 $style = $tp->get_attribute('style');
88 88 if (is_string($style) && stripos($style, 'background-image') !== false) {
89 89 $tp->set_attribute('style', preg_replace_callback(
90 90 '/background-image\s*:\s*url\([^)]*\)/i',
91 - static fn () => 'background-image:url(' . $url . ')',
91 + static function () use ($url) {
92 + return 'background-image:url(' . $url . ')';
93 + },
92 94 $style
93 95 ));
94 96 $patched = true;
95 97 }
@@ -101,22 +103,19 @@
101 103 if ($alt !== null) {
102 104 $tp->set_attribute('alt', $alt);
103 105 }
104 106
105 - // Gutenberg's media-text save() derives wp-image-{id} from
106 - // attrs.mediaId; a mismatch trips the validator. Strip any
107 - // pre-existing first so re-edits don't stack.
108 - $cls = (string) ($tp->get_attribute('class') ?? '');
109 - $cls = trim((string) preg_replace('/\bwp-image-\d+\b/', '', $cls));
107 + // Core's save() derives wp-image-{id} + size-{mediaSizeSlug||full}
108 + // from attrs; mismatched markup trips the block validator.
109 + foreach ($tp->class_list() as $class) {
110 + if (str_starts_with($class, 'wp-image-') || str_starts_with($class, 'size-')) {
111 + $tp->remove_class($class);
112 + }
113 + }
110 114 if ($id !== null && $id > 0) {
111 - $cls = trim($cls . ' wp-image-' . $id);
115 + $tp->add_class('wp-image-' . $id);
116 + $tp->add_class('size-' . ($attrs['mediaSizeSlug'] ?? 'full'));
112 117 }
113 - $cls = (string) preg_replace('/\s{2,}/', ' ', $cls);
114 - if ($cls === '') {
115 - $tp->remove_attribute('class');
116 - } else {
117 - $tp->set_attribute('class', $cls);
118 - }
119 118
120 119 if ($id === null || $id <= 0) {
121 120 $tp->remove_attribute('srcset');
122 121 $tp->remove_attribute('sizes');
@@ -130,9 +129,11 @@
130 129 $innerContent[$i] = $patchedChunk;
131 130 $block['innerContent'] = $innerContent;
132 131 // Inspection-only; the serializer rebuilds innerHTML from innerContent.
133 132 $block['innerHTML'] = implode('', array_map(
134 - static fn ($c) => is_string($c) ? $c : '',
133 + static function ($c) {
134 + return is_string($c) ? $c : '';
135 + },
135 136 $innerContent
136 137 ));
137 138 break;
138 139 }
@@ -150,9 +151,11 @@
150 151 return $attrs;
151 152 }
152 153 $classes = array_filter(
153 154 preg_split('/\s+/', $attrs['className']) ?: [],
154 - static fn ($c) => $c !== '' && $c !== 'extendify-image-import'
155 + static function ($c) {
156 + return $c !== '' && $c !== 'extendify-image-import';
157 + }
155 158 );
156 159 if ($classes) {
157 160 $attrs['className'] = implode(' ', $classes);
158 161 } else {