post_parent ) { $parent_value = get_metadata( 'post', $item->post_parent, 'ref_offer', true ); } else { $parent_value = ''; } // Add/replace the value if it has changed if ( $old_value != $parent_value ) { $updates['custom_updates'][ 'ref_offer' ] = $parent_value; } return $updates; } // mla_mapping_updates /** * WordPress save post action * * This action is called AFTER the post has been added or updated in the posts database table. * It is used to map or re-map the IPTC/EXIF and custom field rules. * * @since 1.01 * * @param integer post ID to be evaluated * @param object post content * @param boolean true if update, false if insert */ public static function save_post( $post_id, $post, $update ) { // If this is just a revision, exit. if ( wp_is_post_revision( $post_id ) ) { return; } // You may need to add MIME types other than 'image' for your application foreach ( get_attached_media( 'image' , $post_id ) as $attachment_id => $value) { $updates = MLAOptions::mla_evaluate_custom_field_mapping( $attachment_id, 'single_attachment_mapping' ); if ( !empty( $updates ) ) { $item_content = MLAData::mla_update_single_item( $attachment_id, $updates ); } } } // save_post } //MLAMappingParentDataExample /* * Install the filters at an early opportunity */ add_action('init', 'MLAMappingParentDataExample::initialize'); ?>