'post', ); } protected function get_mapping_fields() { return array( array( 'value' => '_thumbnail_id', 'label' => __( 'Featured Image', 'airwpsync' ), 'enabled' => true, ), array( 'value' => 'custom_field', 'label' => __( 'Custom Field (Pro version, coming soon)', 'airwpsync' ), 'enabled' => false, ), ); } public function add_metas( $importer, $fields, $record, $post_id ) { $mapped_fields = $this->get_my_mapping( $importer, $fields ); foreach ( $mapped_fields as $mapped_field ) { if ( '_thumbnail_id' === $mapped_field['wordpress'] ) { $value = $fields[ $mapped_field['airtable'] ] ?? false; if ( is_array( $value ) ) { $value = array_shift( $value ); } if ( ! empty( $value ) && ! is_int( $value ) ) { throw new Exception( __( 'The Airtable field mapped to the featured image seems invalid.', 'airwpsync' ) ); } $key = $mapped_field['wordpress']; } else { $value = $fields[ $mapped_field['airtable'] ] ?? ''; $key = $mapped_field['options']['name'] ?? false; } if ( ! empty( $key ) ) { update_post_meta( $post_id, $key, $value ); } } } } new Air_WP_Sync_Meta_Destination();