From 8fc4ccac3094c0f014184a9021b21b75635479d3 Mon Sep 17 00:00:00 2001 From: Luca Tumedei Date: Tue, 3 Sep 2024 11:54:29 +0200 Subject: [PATCH] refactor(Admin/Fields/Field) render license key field when required by OAuth --- src/Uplink/Admin/Fields/Field.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Uplink/Admin/Fields/Field.php b/src/Uplink/Admin/Fields/Field.php index 583c2e07..90e84b8d 100644 --- a/src/Uplink/Admin/Fields/Field.php +++ b/src/Uplink/Admin/Fields/Field.php @@ -235,17 +235,23 @@ public function render( array $args = [] ): void { public function get_render_html(): string { $this->asset_manager->enqueue_assets(); + $args = [ + 'field' => $this, + 'group' => $this->group->get_name( $this->get_slug() ), + ]; + if ( $this->resource->is_using_oauth() ) { ob_start(); + + if ( $this->resource->oauth_requires_license_key() ) { + echo $this->view->render( self::VIEW, $args ); + } + UplinkNamespace\render_authorize_button( $this->get_slug() ); + return (string) ob_get_clean(); } - $args = [ - 'field' => $this, - 'group' => $this->group->get_name( $this->get_slug() ), - ]; - $html = $this->view->render( self::VIEW, $args ); /**