Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions custom_metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -535,12 +535,19 @@ function save_metadata_group( $group_slug, $group, $object_type, $object_id ) {
}

function save_metadata_field( $field_slug, $field, $object_type, $object_id ) {
if( isset( $_POST[$field_slug] ) ) {
$value = $this->_sanitize_field_value( $field_slug, $field, $object_type, $object_id, $_POST[$field_slug] );
$this->_save_field_value( $field_slug, $field, $object_type, $object_id, $value );
} else {
$this->_delete_field_value( $field_slug, $field, $object_type, $object_id );
}
$value = null;
if( isset( $_POST[$field_slug] ) )
$value = $this->_sanitize_field_value( $field_slug, $field, $object_type, $object_id, $_POST[$field_slug] );

$save_callback = $this->_get_save_callback( $field );
if( $save_callback )
return call_user_func( $save_callback, $field_slug, $field, $object_type, $object_id, $value );

if( isset( $value ) ){
$this->_save_field_value( $field_slug, $field, $object_type, $object_id, $value );
} else {
$this->_delete_field_value( $field_slug, $field, $object_type, $object_id );
}
}

function get_metadata_field_value( $field_slug, $field, $object_type, $object_id ) {
Expand Down Expand Up @@ -777,10 +784,7 @@ function _get_field_value( $field_slug, $field, $object_type, $object_id ) {

function _save_field_value( $field_slug, $field, $object_type, $object_id, $value ) {

$save_callback = $this->_get_save_callback( $field );

if( $save_callback )
return call_user_func( $save_callback, $object_type, $object_id, $field_slug, $value );


if( ! in_array( $object_type, $this->_non_post_types ) )
$object_type = 'post';
Expand Down