Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WordPressKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Pod::Spec.new do |s|
s.name = 'WordPressKit'
s.version = '4.51.0-beta.1'
s.version = '4.51.0-beta.2'

s.summary = 'WordPressKit offers a clean and simple WordPress.com and WordPress.org API.'
s.description = <<-DESC
Expand Down
14 changes: 12 additions & 2 deletions WordPressKit/Insights/StatsLastPostInsight.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,24 @@ public struct StatsLastPostInsight {
public let commentsCount: Int
public let viewsCount: Int
public let postID: Int
public let featuredImageURL: URL?

public init(title: String,
url: URL,
publishedDate: Date,
likesCount: Int,
commentsCount: Int,
viewsCount: Int,
postID: Int) {
postID: Int,
featuredImageURL: URL?) {
self.title = title
self.url = url
self.publishedDate = publishedDate
self.likesCount = likesCount
self.commentsCount = commentsCount
self.viewsCount = viewsCount
self.postID = postID
self.featuredImageURL = featuredImageURL
}
}

Expand All @@ -31,7 +34,7 @@ extension StatsLastPostInsight: StatsInsightData {
return ["order_by": "date",
"number": "1",
"type": "post",
"fields": "ID, title, URL, discussion, like_count, date"]
"fields": "ID, title, URL, discussion, like_count, date, featured_image"]
}

public static var pathComponent: String {
Expand Down Expand Up @@ -69,5 +72,12 @@ extension StatsLastPostInsight: StatsInsightData {
self.commentsCount = commentsCount
self.viewsCount = views
self.postID = postID

if let featuredImage = jsonDictionary["featured_image"] as? String,
let featuredURL = URL(string: featuredImage) {
self.featuredImageURL = featuredURL
} else {
self.featuredImageURL = nil
}
}
}