Kingdom Creation
Forum Replies Created
-
Forum: Plugins
In reply to: [DrawIt (draw.io)] Editing diagram problemssame here!
data in wp_postmeta says “A” for _wp_attachment_metadata. I believe there might be an issue while saving the draw.io xml data to meta data array.WordPress 4.8.1
Tested without other plugins!Forum: Plugins
In reply to: [WP REST API (WP API)] Need to 'prepare_post' dataHi,
It seems that the variable global $wp_json_posts; is undefined in my context. I believe this may be somehow related to the fact that i’m using it outside the server process upon save_post.
Currently i’m converting a large array that contains ‘WP_Post’ and authors and all kinds of WordPress data objects.
I considered parsing the properties and renaming the indexes kinda like the api does in ‘prepare_post’ but it just seems so redundant.
What i do then is save the data in a post_meta. ( and i would like it to be saved formatted the same way the api does). In another context i then pull the data back when that api summoned, I use the fillowing code.
functions.php
add_filter( 'json_prepare_post', function ($data, $post, $context) { $data['post_meta'] = get_post_meta( $post['ID'],'_data', true ); return $data; }, 10, 3 );But as you can see above in my original question, the json from the api is formatted by the api to look nice and be useful (author instead of post_author, with meaningful data inside not just an index) but the data i added ‘post_meta‘ contains some data that isn’t nicely formatted.
All i would need really would be the create an instance of the WP_JSON_Posts but the authors @ryanmccue made it so i think it shoulnt be instantiated outside of it’s server component.
Although the function ‘get_post’ (witch i think is the one @rjvansant suggested would be super useful. and is basically what i need, it’s right there just i can use it in the admin)
So i considered, what if i use PHP to query the API and get the formatted data that way, i tried curl, i tried file_get_contents etc. even i tried to get @ryanmccue php-client in my theme….
- . Is there a way to reuse the api formatting blocs used ‘in’ the api outside the api.
The other hook inside my function is
add_action('save_post', 'update_data',20,1); function update_data($post_id){ <em> global $wp_json_posts; // @rjvansant</em> ... }Thanks! @rjvansant
Forum: Plugins
In reply to: [WP REST API (WP API)] Need to 'prepare_post' dataIt’s seems like i found a related request here:
I just posted a support request that seems similar, perhaps we are trying to achieve the same thing.