@@ -189,7 +189,7 @@ public function enqueue_assets( string $hook_suffix ): void {
189189
190190 $ current_tab = $ this ->get_current_tab ();
191191
192- if ( 'settings ' === $ current_tab ) {
192+ if ( in_array ( $ current_tab , [ 'settings ' , ' organization ' ], true ) ) {
193193 add_thickbox ();
194194 }
195195
@@ -482,17 +482,6 @@ function () {
482482 self ::ORG_PAGE ,
483483 'workos_organization '
484484 );
485-
486- // --- Create Organization ---
487- add_settings_section (
488- 'workos_create_org ' ,
489- __ ( 'Create Organization ' , 'workos ' ),
490- function () {
491- echo '<p> ' . esc_html__ ( 'Create a new organization in WorkOS and automatically select it. ' , 'workos ' ) . '</p> ' ;
492- $ this ->render_create_org_form ();
493- },
494- self ::ORG_PAGE
495- );
496485 }
497486
498487 /**
@@ -1049,36 +1038,39 @@ public function render_organization_select(): void {
10491038 );
10501039 }
10511040 echo '</select> ' ;
1041+ printf (
1042+ '<p><a href="#TB_inline?width=400&height=250&inlineId=workos-create-org-modal" class="thickbox">%s</a></p> ' ,
1043+ esc_html__ ( 'Create new organization ' , 'workos ' )
1044+ );
1045+
1046+ $ this ->render_create_org_modal ();
10521047 }
10531048
10541049 /**
1055- * Render the inline Create Organization form .
1050+ * Render the hidden Thickbox modal for creating an organization .
10561051 */
1057- private function render_create_org_form (): void {
1058- if ( Config::is_overridden ( 'organization_id ' ) ) {
1059- echo '<p class="description"> ' . esc_html__ ( 'Organization is set via constant. ' , 'workos ' ) . '</p> ' ;
1060- return ;
1061- }
1062-
1052+ private function render_create_org_modal (): void {
10631053 $ editing_env = $ this ->get_editing_environment ();
10641054 ?>
1065- <form method="post" action="<?php echo esc_url ( admin_url ( 'admin-post.php ' ) ); ?> " style="max-width: 500px;">
1066- <?php wp_nonce_field ( 'workos_create_org ' ); ?>
1067- <input type="hidden" name="action" value="workos_create_org" />
1068- <input type="hidden" name="editing_env" value="<?php echo esc_attr ( $ editing_env ); ?> " />
1069- <table class="form-table" role="presentation">
1070- <tr>
1071- <th scope="row">
1072- <label for="workos_org_name"><?php esc_html_e ( 'Organization Name ' , 'workos ' ); ?> </label>
1073- </th>
1074- <td>
1075- <input type="text" id="workos_org_name" name="org_name" class="regular-text" required />
1076- <p class="description"><?php esc_html_e ( 'Name for the new WorkOS organization. ' , 'workos ' ); ?> </p>
1077- </td>
1078- </tr>
1079- </table>
1080- <?php submit_button ( __ ( 'Create Organization ' , 'workos ' ), 'secondary ' ); ?>
1081- </form>
1055+ <div id="workos-create-org-modal" style="display:none">
1056+ <form method="post" action="<?php echo esc_url ( admin_url ( 'admin-post.php ' ) ); ?> ">
1057+ <?php wp_nonce_field ( 'workos_create_org ' ); ?>
1058+ <input type="hidden" name="action" value="workos_create_org" />
1059+ <input type="hidden" name="editing_env" value="<?php echo esc_attr ( $ editing_env ); ?> " />
1060+ <table class="form-table" role="presentation">
1061+ <tr>
1062+ <th scope="row">
1063+ <label for="workos_org_name"><?php esc_html_e ( 'Organization Name ' , 'workos ' ); ?> </label>
1064+ </th>
1065+ <td>
1066+ <input type="text" id="workos_org_name" name="org_name" class="regular-text" required />
1067+ <p class="description"><?php esc_html_e ( 'Name for the new WorkOS organization. ' , 'workos ' ); ?> </p>
1068+ </td>
1069+ </tr>
1070+ </table>
1071+ <?php submit_button ( __ ( 'Create Organization ' , 'workos ' ), 'secondary ' ); ?>
1072+ </form>
1073+ </div>
10821074 <?php
10831075 }
10841076
0 commit comments