post_type || 'trash' === $post->post_status || !current_user_can('edit_post', $post->ID) ) { return new WP_Error('apeari_document', __('Nie możesz edytować tej strony.', 'apeari'), [ 'status' => 403, ]); } return self::document($ref, get_the_title($post), $post->post_content, false); } return new WP_Error( 'apeari_ref', __('Edytor zapisuje wyłącznie treść Gutenberga wybranej strony.', 'apeari'), [ 'status' => 403, ], ); } private static function document(string $ref, string $title, string $original, bool $global): array { $content = self::editable_content($original); return [ 'ref' => $ref, 'title' => $title, 'content' => $content, 'originalContent' => $original, 'hash' => hash('sha256', $original . "\0" . $content), 'version' => hash('sha256', $content), 'global' => $global, ]; } public static function editable_content(string $content): string { if (!str_contains($content, '