Skip to content

Commit 525ff6d

Browse files
authored
Use tags and categories endpoints in wordpress-rs (#24665)
* Use tags and categories endpoints in wordpress-rs * Remove `defaultPerPage` * Update wordpress-rs * Update API mocks for tags and categories * Fix compiling issues in the Reader app
1 parent f0bdcae commit 525ff6d

File tree

7 files changed

+342
-72
lines changed

7 files changed

+342
-72
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,90 @@
11
{
22
"request": {
33
"method": "GET",
4-
"urlPath": "/rest/v1.1/sites/106707880/taxonomies/category/terms/"
4+
"urlPath": "/wp/v2/sites/106707880/categories"
55
},
66
"response": {
77
"status": 200,
8-
"jsonBody": {
9-
"found": 3,
10-
"terms": [
11-
{
12-
"ID": 1,
13-
"name": "Uncategorized",
14-
"slug": "uncategorized",
15-
"description": "",
16-
"post_count": 1,
17-
"feed_url": "http://tricountyrealestate.wordpress.com/category/uncategorized/feed/",
18-
"parent": 0,
19-
"meta": {
20-
"links": {
21-
"self": "{{request.requestLine.baseUrl}}/rest/v1.1/sites/106707880/categories/slug:uncategorized",
22-
"help": "{{request.requestLine.baseUrl}}/rest/v1.1/sites/106707880/categories/slug:uncategorized/help",
23-
"site": "{{request.requestLine.baseUrl}}/rest/v1.1/sites/106707880"
24-
}
25-
}
26-
},
27-
{
28-
"ID": 1674,
29-
"name": "Wedding",
30-
"slug": "wedding",
31-
"description": "",
32-
"post_count": 1,
33-
"feed_url": "http://tricountyrealestate.wordpress.com/category/wedding/feed/",
34-
"parent": 0,
35-
"meta": {
36-
"links": {
37-
"self": "{{request.requestLine.baseUrl}}/rest/v1.1/sites/106707880/categories/slug:wedding",
38-
"help": "{{request.requestLine.baseUrl}}/rest/v1.1/sites/106707880/categories/slug:wedding/help",
39-
"site": "{{request.requestLine.baseUrl}}/rest/v1.1/sites/106707880"
40-
}
41-
}
8+
"jsonBody": [
9+
{
10+
"id": 1,
11+
"count": 1,
12+
"description": "",
13+
"link": "http://tricountyrealestate.wordpress.com/category/uncategorized/",
14+
"name": "Uncategorized",
15+
"slug": "uncategorized",
16+
"taxonomy": "category",
17+
"parent": 0,
18+
"meta": [],
19+
"_links": {
20+
"self": [
21+
{
22+
"href": "{{request.requestLine.baseUrl}}/wp-json/wp/v2/categories/1",
23+
"targetHints": { "allow": ["GET", "POST", "PUT", "PATCH", "DELETE"] }
24+
}
25+
],
26+
"collection": [
27+
{
28+
"href": "{{request.requestLine.baseUrl}}/wp-json/wp/v2/categories"
29+
}
30+
],
31+
"about": [
32+
{
33+
"href": "{{request.requestLine.baseUrl}}/wp-json/wp/v2/taxonomies/category"
34+
}
35+
],
36+
"wp:post_type": [
37+
{
38+
"href": "{{request.requestLine.baseUrl}}/wp-json/wp/v2/posts?categories=1"
39+
}
40+
],
41+
"curies": [
42+
{ "name": "wp", "href": "https://api.w.org/{rel}", "templated": true }
43+
]
44+
}
45+
},
46+
{
47+
"id": 1674,
48+
"count": 1,
49+
"description": "",
50+
"link": "http://tricountyrealestate.wordpress.com/category/wedding/",
51+
"name": "Wedding",
52+
"slug": "wedding",
53+
"taxonomy": "category",
54+
"parent": 0,
55+
"meta": [],
56+
"_links": {
57+
"self": [
58+
{
59+
"href": "{{request.requestLine.baseUrl}}/wp-json/wp/v2/categories/1674",
60+
"targetHints": { "allow": ["GET", "POST", "PUT", "PATCH", "DELETE"] }
61+
}
62+
],
63+
"collection": [
64+
{
65+
"href": "{{request.requestLine.baseUrl}}/wp-json/wp/v2/categories"
66+
}
67+
],
68+
"about": [
69+
{
70+
"href": "{{request.requestLine.baseUrl}}/wp-json/wp/v2/taxonomies/category"
71+
}
72+
],
73+
"wp:post_type": [
74+
{
75+
"href": "{{request.requestLine.baseUrl}}/wp-json/wp/v2/posts?categories=1674"
76+
}
77+
],
78+
"curies": [
79+
{ "name": "wp", "href": "https://api.w.org/{rel}", "templated": true }
80+
]
4281
}
43-
]
44-
},
82+
}
83+
],
4584
"headers": {
4685
"Content-Type": "application/json",
4786
"Connection": "keep-alive",
4887
"Cache-Control": "no-cache, must-revalidate, max-age=0"
4988
}
5089
}
51-
}
90+
}
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,26 @@
11
{
22
"request": {
33
"method": "GET",
4-
"urlPath": "/rest/v1.1/sites/106707880/taxonomies/post_tag/terms/",
5-
"queryParameters": {
6-
"number": {
7-
"equalTo": "1000"
8-
},
9-
"locale": {
10-
"matches": "(.*)"
11-
}
12-
}
4+
"urlPath": "/wp/v2/sites/106707880/tags"
135
},
146
"response": {
157
"status": 200,
16-
"jsonBody": {
17-
"found": 1,
18-
"terms": [
19-
{
20-
"ID": 2500,
21-
"name": "tag",
22-
"slug": "tag",
23-
"description": "",
24-
"post_count": 1,
25-
"feed_url": "https://tricountyrealestate.wordpress.com/tag/tag/feed/",
26-
"meta": {
27-
"links": {
28-
"self": "{{request.requestLine.baseUrl}}/rest/v1.1/sites/106707880/tags/slug:tag",
29-
"help": "{{request.requestLine.baseUrl}}/rest/v1.1/sites/106707880/tags/slug:tag/help",
30-
"site": "{{request.requestLine.baseUrl}}/rest/v1.1/sites/106707880"
31-
}
32-
}
33-
}
34-
]
35-
},
8+
"jsonBody": [
9+
{
10+
"id": 2500,
11+
"count": 1,
12+
"description": "",
13+
"link": "https://tricountyrealestate.wordpress.com/tag/tag/",
14+
"name": "tag",
15+
"slug": "tag",
16+
"taxonomy": "post_tag",
17+
"meta": []
18+
}
19+
],
3620
"headers": {
3721
"Content-Type": "application/json",
3822
"Connection": "keep-alive",
3923
"Cache-Control": "no-cache, must-revalidate, max-age=0"
4024
}
4125
}
42-
}
26+
}

Modules/Package.resolved

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ let package = Package(
5353
),
5454
.package(url: "https://github.com/zendesk/support_sdk_ios", from: "8.0.3"),
5555
// We can't use wordpress-rs branches nor commits here. Only tags work.
56-
.package(url: "https://github.com/Automattic/wordpress-rs", revision: "alpha-20250707"),
56+
.package(url: "https://github.com/Automattic/wordpress-rs", revision: "alpha-20250715"),
5757
.package(url: "https://github.com/wordpress-mobile/GutenbergKit", from: "0.4.1"),
5858
.package(
5959
url: "https://github.com/Automattic/color-studio",

WordPress/Classes/Services/PostCategoryService.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ - (void)mergeCategories:(NSArray <RemotePostCategory *> *)remoteCategories forBl
180180
}
181181

182182
- (nullable id<TaxonomyServiceRemote>)remoteForBlog:(Blog *)blog {
183+
TaxonomyServiceRemoteCoreREST *instance = [[TaxonomyServiceRemoteCoreREST alloc] initWithBlog:blog];
184+
if (instance != nil) {
185+
return instance;
186+
}
187+
183188
if ([blog supports:BlogFeatureWPComRESTAPI]) {
184189
if (blog.wordPressComRestApi) {
185190
return [[TaxonomyServiceRemoteREST alloc] initWithWordPressComRestApi:blog.wordPressComRestApi siteID:blog.dotComID];

WordPress/Classes/Services/PostTagService.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ - (void)saveTag:(PostTag*)tag
159159
#pragma mark - helpers
160160

161161
- (nullable id<TaxonomyServiceRemote>)remoteForBlog:(Blog *)blog {
162+
TaxonomyServiceRemoteCoreREST *instance = [[TaxonomyServiceRemoteCoreREST alloc] initWithBlog:blog];
163+
if (instance != nil) {
164+
return instance;
165+
}
166+
162167
if ([blog supports:BlogFeatureWPComRESTAPI]) {
163168
if (blog.wordPressComRestApi) {
164169
return [[TaxonomyServiceRemoteREST alloc] initWithWordPressComRestApi:blog.wordPressComRestApi siteID:blog.dotComID];

0 commit comments

Comments
 (0)