Skip to content

Commit 9f2f086

Browse files
authored
Update posts.php
1 parent 85c585a commit 9f2f086

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

posts.php

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,30 @@
1515
$posts = '';
1616
if (isset($feed['entry']) && is_array($feed['entry'])) {
1717
foreach ($feed['entry'] as $post) {
18-
$date = date('d/m/Y', strtotime($post['updated'] ?? ''));
19-
$title = $post['title'] ?? 'Untitled';
20-
21-
// Handle link as array or string
22-
$link = is_array($post['link']) ? ($post['link']['@attributes']['href'] ?? '#') : ($post['link'] ?? '#');
18+
// Format the date
19+
$date = isset($post['updated']) ? date('d/m/Y', strtotime($post['updated'])) : 'Unknown Date';
2320

24-
// Ensure description is a string
25-
$description = isset($post['summary']) ? (is_string($post['summary']) ? strip_tags($post['summary']) : strip_tags($post['summary'][0])) : '';
21+
// Ensure title is available
22+
$title = $post['title'] ?? 'Untitled';
23+
24+
// Extract the link URL
25+
if (isset($post['link'])) {
26+
if (is_array($post['link'])) {
27+
$link = $post['link']['@attributes']['href'] ?? '#';
28+
} else {
29+
$link = $post['link'];
30+
}
31+
} else {
32+
$link = '#';
33+
}
34+
35+
// Extract the description or summary
36+
$description = '';
37+
if (isset($post['summary'])) {
38+
$description = is_string($post['summary']) ? strip_tags($post['summary']) : (isset($post['summary'][0]) ? strip_tags($post['summary'][0]) : '');
39+
}
2640

41+
// Format each post entry
2742
$posts .= sprintf(
2843
"\n* **[%s]** [%s](%s \"%s\")\n > %s",
2944
$date,

0 commit comments

Comments
 (0)