Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey,
I'm proposing two changes:
Featured Image
This was a tricky one. I needed a possibility to check if a post had a featured image and compare its filename to a local file. So I added to Post.cs:
Unfortunately the value retrieved from the WP API is not consistent. If a post has no featured image, I get back:
which can't be converted into MediaItem. So I went for object and later parsing via methods:
and I introduced an extension method for XmlRpcStruct using reflection to populate MediaItem.
Custom Fields
I was trying to generate maps for the Google Maps Builder plugin. Internally all maps are stored as posts. Some of the custom fields required complex values though, such as:
I could not find a way to create and pass this as a string. WP would just escape it and save it as a string, instead of the value intended. The only way I could find was to pass complex objects as custom field values, instead of strings. Example:
I created the classes with mapping accordingly:
Works also with nested classes. WP receives the object, turns it into its string format and stores it. This is not only required for use with the plugin above but many plugins and themes.
Long story short: I propose changing the data type of the Custom Field value from string to object.