feat: render summary notes global modules it cannot show (F8)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
This commit is contained in:
@@ -19,6 +19,9 @@ defined('ABSPATH') || exit;
|
||||
*/
|
||||
final class PageRenderSummaryAbility implements Ability
|
||||
{
|
||||
/** At most this many global-module notes per summary. */
|
||||
private const GLOBAL_NOTES = 20;
|
||||
|
||||
public function __construct(private ContentSchema $schema, private PageRenderer $renderer)
|
||||
{
|
||||
}
|
||||
@@ -40,7 +43,8 @@ final class PageRenderSummaryAbility implements Ability
|
||||
. 'Alt-Texte). Header, Footer und Theme-Builder-Vorlagen sind nicht enthalten. Das Rendern führt die '
|
||||
. 'üblichen Inhalts-Filter aus (Shortcodes, Divi, andere Plugins) und kann dabei Netzwerkanfragen '
|
||||
. 'auslösen, z. B. oEmbed-Abrufe, die von WordPress oder anderen Plugins zwischengespeichert werden. '
|
||||
. 'Gut zum Prüfen nach Änderungen.';
|
||||
. 'Gut zum Prüfen nach Änderungen. Globale Module (Divi-Bibliothek) fehlen im Auszug und werden '
|
||||
. 'unter notes genannt.';
|
||||
}
|
||||
|
||||
public function inputSchema(): array
|
||||
@@ -104,10 +108,32 @@ final class PageRenderSummaryAbility implements Ability
|
||||
$notes[] = 'Der Eintrag ist passwortgeschützt; Besucher sehen zuerst das Passwortformular.';
|
||||
}
|
||||
|
||||
foreach (array_slice(self::globalModuleIds((string) $post->post_content), 0, self::GLOBAL_NOTES) as $id) {
|
||||
$notes[] = sprintf(
|
||||
'Globales Modul %s ist im Auszug nicht enthalten (beim Aufruf über die Schnittstelle rendert Divi '
|
||||
. 'globale Module nicht); Inhalt mit lit-divi-outline mit post_id %s lesen.',
|
||||
$id,
|
||||
$id
|
||||
);
|
||||
}
|
||||
|
||||
return array_merge(
|
||||
['post_id' => (int) $post->ID, 'url' => (string) get_permalink($post)],
|
||||
RenderSummary::fromHtml($this->renderer->render($post)),
|
||||
['notes' => $notes]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* IDs of the global modules in $content, found the way Divi finds them (a string scan for
|
||||
* "globalModule", BlockParserStore::get_global_layout_content – parse_blocks() is unreliable there).
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
private static function globalModuleIds(string $content): array
|
||||
{
|
||||
preg_match_all('/"globalModule":"?(\d+)"?/', $content, $matches);
|
||||
|
||||
return array_values(array_unique($matches[1]));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user