prepare_data( $comment_id, $data ), $data ); $this->send_data( $comment_id, 'comment', self::$action, $fields ); } /** * Sends updated WP comment details to AINSYS. * * @param int $comment_id * @param array $data * */ public function process_update( int $comment_id, array $data ): void { self::$action = 'UPDATE'; if ( Conditions::has_entity_disable( self::$entity, self::$action ) ) { return; } $fields = apply_filters( 'ainsys_process_update_fields_' . self::$entity, $this->prepare_data( $comment_id, $data ), $data ); $this->send_data( $comment_id, 'comment', self::$action, $fields ); } /** * Sends updated WP comment details to AINSYS. * * @param int $comment_id * @param array $data * * @return array */ public function process_checking( int $comment_id, array $data ): array { self::$action = 'CHECKING'; if ( Conditions::has_entity_disable( self::$entity, self::$action ) ) { return []; } $fields = apply_filters( 'ainsys_process_update_fields_' . self::$entity, $this->prepare_data( $comment_id, $data ), $data ); return $this->send_data( $comment_id, 'comment', self::$action, $fields ); } /** * Prepares WP comment data. Adds ACF fields if there are any. * * @param int $comment_id * @param array $data * * @return array */ private function prepare_data( $comment_id, $data ) { $data['id'] = $comment_id; /// Get ACF fields $acf_fields = apply_filters( 'ainsys_prepare_extra_comment_data', [], $comment_id ); return array_merge( $data, $acf_fields ); } }