This repository was archived by the owner on Sep 15, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed
Sources/WordPressKit/Services
Tests/WordPressKitTests/Tests Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -60,13 +60,15 @@ typedef void(^ThemeServiceRemoteFailureBlock)(NSError *error);
6060 *
6161 * @param freeOnly Only fetch free themes, if false all WP themes will be returned
6262 * @param page Results page to return.
63+ * @param search Search term to filter themes. Can be nil or empty string.
6364 * @param success The success handler. Can be nil.
6465 * @param failure The failure handler. Can be nil.
6566 *
6667 * @returns A progress object that can be used to track progress and/or cancel the task
6768 */
6869- (NSProgress *)getWPThemesPage : (NSInteger )page
6970 freeOnly : (BOOL )freeOnly
71+ search : (NSString *)search
7072 success : (ThemeServiceRemoteThemesRequestSuccessBlock)success
7173 failure : (ThemeServiceRemoteFailureBlock)failure ;
7274
Original file line number Diff line number Diff line change @@ -99,6 +99,7 @@ - (NSProgress *)getThemeId:(NSString*)themeId
9999
100100- (NSProgress *)getWPThemesPage : (NSInteger )page
101101 freeOnly : (BOOL )freeOnly
102+ search : (NSString *)search
102103 success : (ThemeServiceRemoteThemesRequestSuccessBlock)success
103104 failure : (ThemeServiceRemoteFailureBlock)failure
104105{
@@ -107,10 +108,15 @@ - (NSProgress *)getWPThemesPage:(NSInteger)page
107108 NSString *requestUrl = [self pathForEndpoint: @" themes"
108109 withVersion: WordPressComRESTAPIVersion_1_2];
109110
110- NSDictionary *parameters = @{ThemeRequestTierKey: freeOnly ? ThemeRequestTierFreeValue : ThemeRequestTierAllValue,
111- ThemeRequestNumberKey: @(ThemeRequestNumberValue),
112- ThemeRequestPageKey: @(page),
113- };
111+ NSMutableDictionary *parameters = [@{
112+ ThemeRequestTierKey: freeOnly ? ThemeRequestTierFreeValue : ThemeRequestTierAllValue,
113+ ThemeRequestNumberKey: @(ThemeRequestNumberValue),
114+ ThemeRequestPageKey: @(page)
115+ } mutableCopy];
116+
117+ if (search && search.length > 0 ) {
118+ parameters[@" search" ] = search;
119+ }
114120
115121 return [self getThemesWithRequestUrl: requestUrl
116122 page: page
Original file line number Diff line number Diff line change @@ -225,6 +225,7 @@ - (void)testThatGetThemesWorks
225225
226226 XCTAssertNoThrow ([service getWPThemesPage: 1
227227 freeOnly: NO
228+ search: nil
228229 success: successBlock
229230 failure: nil ]);
230231}
You can’t perform that action at this time.
0 commit comments