get_var( $wpdb->prepare( "SELECT batch_id FROM {$wpdb->prefix}icl_translation_status WHERE translation_id=%d", $data['translation_id'] ) ); // if the batch id is smaller than 1 we assign the translation to the generic manual translations batch for today if the translation_service is local if ( ( $batch_id < 1 ) && isset( $data ['translation_service'] ) && $data ['translation_service'] == 'local' ) { // first we retrieve the batch id for today's generic translation batch $batch_id = self::create_generic_batch(); // then we update the entry in the icl_translation_status table accordingly $data_where = array( 'rid' => $data['rid'] ); $wpdb->update( $wpdb->prefix . 'icl_translation_status', array( 'batch_id' => $batch_id ), $data_where ); } } /** * @param $batch_name * @param $tp_id * * @return mixed */ private static function createBatchRecord( $batch_name, $tp_id ) { global $wpdb; $data = [ 'batch_name' => $batch_name, 'last_update' => date( 'Y-m-d H:i:s' ), ]; if ( $tp_id ) { $data['tp_id'] = $tp_id === 'local' ? 0 : $tp_id; } $wpdb->insert( $wpdb->prefix . 'icl_translation_batches', $data ); return $wpdb->insert_id; } } /** * @param $batch_name * * @return mixed */ TranslationProxy_Batch::macro( 'getBatchId', curryN( 1, function( $batch_name ) { global $wpdb; $batch_id_sql = "SELECT id FROM {$wpdb->prefix}icl_translation_batches WHERE batch_name=%s"; $batch_id_prepared = $wpdb->prepare( $batch_id_sql, $batch_name ); return $wpdb->get_var( $batch_id_prepared ); } ) );