This repository was archived by the owner on Sep 15, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change 11Pod ::Spec . new do |s |
22 s . name = "WordPressKit"
3- s . version = "4.2.0-beta.2 "
3+ s . version = "4.2.0-beta.3 "
44 s . summary = "WordPressKit offers a clean and simple WordPress.com and WordPress.org API."
55
66 s . description = <<-DESC
Original file line number Diff line number Diff line change @@ -418,10 +418,6 @@ - (NSDictionary *)parametersWithRemotePost:(RemotePost *)post
418418 postParams[@" custom_fields" ] = post.metadata ;
419419 }
420420
421- if (post.isStickyPost != nil ) {
422- postParams[@" sticky" ] = post.isStickyPost .boolValue ? @" true" : @" false" ;
423- }
424-
425421 postParams[@" wp_page_parent_id" ] = post.parentID ? post.parentID .stringValue : @" 0" ;
426422
427423 // Scheduled posts need to sync with a status of 'publish'.
@@ -433,6 +429,21 @@ - (NSDictionary *)parametersWithRemotePost:(RemotePost *)post
433429 post.status = PostStatusPublish;
434430 }
435431
432+ // At least as of 5.2.2, Private and/or Password Protected posts can't be stickied.
433+ // However, the code used on the backend doesn't check the value of the `sticky` field,
434+ // instead doing a simple `! empty( $post_data['sticky'] )` check.
435+ //
436+ // This means we have to omit this field entirely for those posts from the payload we're sending
437+ // to the XML-RPC sevices.
438+ //
439+ // https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-xmlrpc-server.php
440+ //
441+ BOOL shouldIncludeStickyField = ![post.status isEqualToString: PostStatusPrivate] && post.password == nil ;
442+
443+ if (post.isStickyPost != nil && shouldIncludeStickyField) {
444+ postParams[@" sticky" ] = post.isStickyPost .boolValue ? @" true" : @" false" ;
445+ }
446+
436447 if ([post.type isEqualToString: @" page" ]) {
437448 [postParams setObject: post.status forKey: @" page_status" ];
438449 }
You can’t perform that action at this time.
0 commit comments