tengo problema para adaptar este codigo a antonella.
function
Slug_Register_wpcf_created_facebook() {
register_api_field(
'post'
,
'wpcf-created_facebook'
,
array(
'get_callback'
=>
'slug_get_wpcf_created_facebook'
,
'update_callback'
=>
'slug_update_meta_for_api'
,
'schema'
=> null,
)
);
}
add_action(
'rest_api_init'
,
'
Slug_Register_wpcf_created_facebook
');
function
slug_get_wpcf_created_facebook
($post, $field_name, $request) {
return
get_post_meta($post->id, $field_name);
}
function
slug_update_meta_for_api
($value, $post, $field_name) {
if
(!$value || !is_string($value)) {
return
;
}
return
update_post_meta($post->ID, $field_name, strip_tags($value));
}
1 respuestas