| @@ -1,91 +1,92 @@ | ||
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * MCP API keys settings section. | |
| 4 | - * | |
| 5 | - * @var LP_Admin_MCP_API_Keys_Table_List $table | |
| 6 | - * @var array<int, WP_User> $users | |
| 7 | - * @var array<string,string>|null $message | |
| 8 | - */ | |
| 9 | - | |
| 10 | -defined( 'ABSPATH' ) || exit; | |
| 11 | - | |
| 12 | -$default_user = get_current_user_id(); | |
| 13 | -$description = ''; | |
| 14 | -$permissions = 'read'; | |
| 15 | -?> | |
| 16 | - | |
| 17 | -<div class="lp-mcp-api-keys-section"> | |
| 18 | - <?php if ( $message ) : ?> | |
| 19 | - <div class="notice notice-<?php echo esc_attr( $message['type'] ); ?> inline"> | |
| 20 | - <p><?php echo esc_html( $message['message'] ); ?></p> | |
| 21 | - </div> | |
| 22 | - <?php endif; ?> | |
| 23 | - | |
| 24 | - <div class="lp-mcp-key-editor" style="margin: 12px 0 20px; padding: 16px; border: 1px solid #dcdcde; background: #fff;"> | |
| 25 | - <h2 style="margin-top: 0;"><?php esc_html_e( 'Create MCP API Key', 'learnpress' ); ?></h2> | |
| 26 | - <p> | |
| 27 | - <?php esc_html_e( 'Generated credentials are shown once. Store them securely before leaving this page.', 'learnpress' ); ?> | |
| 28 | - </p> | |
| 29 | - | |
| 30 | - <table class="form-table" role="presentation"> | |
| 31 | - <tbody> | |
| 32 | - <tr> | |
| 33 | - <th scope="row"><label for="lp-mcp-key-user"><?php esc_html_e( 'User', 'learnpress' ); ?></label></th> | |
| 34 | - <td> | |
| 35 | - <select id="lp-mcp-key-user" name="mcp_key_user_id"> | |
| 36 | - <?php foreach ( $users as $user ) : ?> | |
| 37 | - <option value="<?php echo esc_attr( $user->ID ); ?>" <?php selected( $default_user, $user->ID ); ?>> | |
| 38 | - <?php echo esc_html( $user->display_name . ' (' . $user->user_login . ')' ); ?> | |
| 39 | - </option> | |
| 40 | - <?php endforeach; ?> | |
| 41 | - </select> | |
| 42 | - </td> | |
| 43 | - </tr> | |
| 44 | - <tr> | |
| 45 | - <th scope="row"><label for="lp-mcp-key-description"><?php esc_html_e( 'Description', 'learnpress' ); ?></label></th> | |
| 46 | - <td> | |
| 47 | - <input type="text" id="lp-mcp-key-description" name="mcp_key_description" class="regular-text" maxlength="200" value="<?php echo esc_attr( $description ); ?>" /> | |
| 48 | - </td> | |
| 49 | - </tr> | |
| 50 | - <tr> | |
| 51 | - <th scope="row"><label for="lp-mcp-key-permissions"><?php esc_html_e( 'Permissions', 'learnpress' ); ?></label></th> | |
| 52 | - <td> | |
| 53 | - <select id="lp-mcp-key-permissions" name="mcp_key_permissions"> | |
| 54 | - <option value="read" <?php selected( $permissions, 'read' ); ?>><?php esc_html_e( 'read', 'learnpress' ); ?></option> | |
| 55 | - <option value="write" <?php selected( $permissions, 'write' ); ?>><?php esc_html_e( 'write', 'learnpress' ); ?></option> | |
| 56 | - <option value="read_write" <?php selected( $permissions, 'read_write' ); ?>><?php esc_html_e( 'read_write', 'learnpress' ); ?></option> | |
| 57 | - </select> | |
| 58 | - </td> | |
| 59 | - </tr> | |
| 60 | - </tbody> | |
| 61 | - </table> | |
| 62 | - | |
| 63 | - <p> | |
| 64 | - <button type="button" class="button button-primary" id="lp-mcp-key-submit"><?php esc_html_e( 'Generate API Key', 'learnpress' ); ?></button> | |
| 65 | - <span id="lp-mcp-key-status" style="margin-left: 10px;"></span> | |
| 66 | - </p> | |
| 67 | - | |
| 68 | - <div id="lp-mcp-key-reveal" style="display:none; margin-top: 12px; padding: 12px; border: 1px solid #2271b1; background: #f0f6fc;"> | |
| 69 | - <p style="margin-top:0;"><strong><?php esc_html_e( 'Copy these credentials now. They will not be shown again.', 'learnpress' ); ?></strong></p> | |
| 70 | - <p> | |
| 71 | - <label><strong><?php esc_html_e( 'Consumer Key', 'learnpress' ); ?></strong></label><br /> | |
| 72 | - <input type="text" readonly id="lp-mcp-consumer-key" class="regular-text code" /> | |
| 73 | - <button type="button" class="button lp-mcp-copy" data-target="lp-mcp-consumer-key"><?php esc_html_e( 'Copy', 'learnpress' ); ?></button> | |
| 74 | - </p> | |
| 75 | - <p> | |
| 76 | - <label><strong><?php esc_html_e( 'Consumer Secret', 'learnpress' ); ?></strong></label><br /> | |
| 77 | - <input type="text" readonly id="lp-mcp-consumer-secret" class="regular-text code" /> | |
| 78 | - <button type="button" class="button lp-mcp-copy" data-target="lp-mcp-consumer-secret"><?php esc_html_e( 'Copy', 'learnpress' ); ?></button> | |
| 79 | - </p> | |
| 80 | - </div> | |
| 81 | - </div> | |
| 82 | - | |
| 83 | - <div class="lp-mcp-key-list" style="background:#fff; padding: 16px; border: 1px solid #dcdcde;"> | |
| 84 | - <h2 style="margin-top:0;"><?php esc_html_e( 'API Keys', 'learnpress' ); ?></h2> | |
| 85 | - <input type="hidden" name="page" value="learn-press-settings" /> | |
| 86 | - <input type="hidden" name="tab" value="mcp" /> | |
| 87 | - <?php wp_nonce_field( 'lp_mcp_bulk_revoke_action', 'lp_mcp_bulk_revoke_nonce' ); ?> | |
| 88 | - <?php $table->search_box( __( 'Search keys', 'learnpress' ), 'lp-mcp-keys-search' ); ?> | |
| 89 | - <?php $table->display(); ?> | |
| 90 | - </div> | |
| 91 | -</div> | |
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * MCP API keys settings section. | |
| 4 | + * | |
| 5 | + * @var LP_Admin_MCP_API_Keys_Table_List $table | |
| 6 | + * @var array<int, WP_User> $users | |
| 7 | + * @var array<string,string>|null $message | |
| 8 | + */ | |
| 9 | + | |
| 10 | +defined( 'ABSPATH' ) || exit; | |
| 11 | + | |
| 12 | +$default_user = get_current_user_id(); | |
| 13 | +$description = ''; | |
| 14 | +$permissions = 'read'; | |
| 15 | +?> | |
| 16 | + | |
| 17 | +<div class="lp-mcp-api-keys-section"> | |
| 18 | + <?php if ( $message ) : ?> | |
| 19 | + <div class="notice notice-<?php echo esc_attr( $message['type'] ); ?> inline"> | |
| 20 | + <p><?php echo esc_html( $message['message'] ); ?></p> | |
| 21 | + </div> | |
| 22 | + <?php endif; ?> | |
| 23 | + | |
| 24 | + <div class="lp-mcp-key-editor" style="margin: 12px 0 20px; padding: 16px; border: 1px solid #dcdcde; background: #fff;"> | |
| 25 | + <h2 style="margin-top: 0;"><?php esc_html_e( 'Create MCP API Key', 'learnpress' ); ?></h2> | |
| 26 | + <p> | |
| 27 | + <?php esc_html_e( 'Generated credentials are shown once. Store them securely before leaving this page.', 'learnpress' ); ?> | |
| 28 | + </p> | |
| 29 | + | |
| 30 | + <table class="form-table" role="presentation"> | |
| 31 | + <tbody> | |
| 32 | + <tr> | |
| 33 | + <th scope="row"><label for="lp-mcp-key-user"><?php esc_html_e( 'User', 'learnpress' ); ?></label></th> | |
| 34 | + <td> | |
| 35 | + <select id="lp-mcp-key-user" name="mcp_key_user_id"> | |
| 36 | + <?php foreach ( $users as $user ) : ?> | |
| 37 | + <option value="<?php echo esc_attr( $user->ID ); ?>" <?php selected( $default_user, $user->ID ); ?>> | |
| 38 | + <?php echo esc_html( $user->display_name . ' (' . $user->user_login . ')' ); ?> | |
| 39 | + </option> | |
| 40 | + <?php endforeach; ?> | |
| 41 | + </select> | |
| 42 | + </td> | |
| 43 | + </tr> | |
| 44 | + <tr> | |
| 45 | + <th scope="row"><label for="lp-mcp-key-description"><?php esc_html_e( 'Description', 'learnpress' ); ?></label></th> | |
| 46 | + <td> | |
| 47 | + <input type="text" id="lp-mcp-key-description" name="mcp_key_description" class="regular-text" maxlength="200" value="<?php echo esc_attr( $description ); ?>" /> | |
| 48 | + </td> | |
| 49 | + </tr> | |
| 50 | + <tr> | |
| 51 | + <th scope="row"><label for="lp-mcp-key-permissions"><?php esc_html_e( 'Permissions', 'learnpress' ); ?></label></th> | |
| 52 | + <td> | |
| 53 | + <select id="lp-mcp-key-permissions" name="mcp_key_permissions"> | |
| 54 | + <option value="read" <?php selected( $permissions, 'read' ); ?>><?php esc_html_e( 'read', 'learnpress' ); ?></option> | |
| 55 | + <option value="write" <?php selected( $permissions, 'write' ); ?>><?php esc_html_e( 'write', 'learnpress' ); ?></option> | |
| 56 | + <option value="read_write" <?php selected( $permissions, 'read_write' ); ?>><?php esc_html_e( 'read_write', 'learnpress' ); ?></option> | |
| 57 | + </select> | |
| 58 | + </td> | |
| 59 | + </tr> | |
| 60 | + </tbody> | |
| 61 | + </table> | |
| 62 | + | |
| 63 | + <p> | |
| 64 | + <button type="button" class="button button-primary" id="lp-mcp-key-submit"><?php esc_html_e( 'Generate API Key', 'learnpress' ); ?></button> | |
| 65 | + <span id="lp-mcp-key-status" style="margin-left: 10px;"></span> | |
| 66 | + </p> | |
| 67 | + | |
| 68 | + <div id="lp-mcp-key-reveal" style="display:none; margin-top: 12px; padding: 12px; border: 1px solid #2271b1; background: #f0f6fc;"> | |
| 69 | + <p style="margin-top:0;"><strong><?php esc_html_e( 'Copy these credentials now. They will not be shown again.', 'learnpress' ); ?></strong></p> | |
| 70 | + <p> | |
| 71 | + <label><strong><?php esc_html_e( 'Consumer Key', 'learnpress' ); ?></strong></label><br /> | |
| 72 | + <input type="text" readonly id="lp-mcp-consumer-key" class="regular-text code" /> | |
| 73 | + <button type="button" class="button lp-mcp-copy" data-target="lp-mcp-consumer-key"><?php esc_html_e( 'Copy', 'learnpress' ); ?></button> | |
| 74 | + </p> | |
| 75 | + <p> | |
| 76 | + <label><strong><?php esc_html_e( 'Consumer Secret', 'learnpress' ); ?></strong></label><br /> | |
| 77 | + <input type="text" readonly id="lp-mcp-consumer-secret" class="regular-text code" /> | |
| 78 | + <button type="button" class="button lp-mcp-copy" data-target="lp-mcp-consumer-secret"><?php esc_html_e( 'Copy', 'learnpress' ); ?></button> | |
| 79 | + </p> | |
| 80 | + </div> | |
| 81 | + </div> | |
| 82 | + | |
| 83 | + <div class="lp-mcp-key-list" style="background:#fff; padding: 16px; border: 1px solid #dcdcde;"> | |
| 84 | + <h2 style="margin-top:0;"><?php esc_html_e( 'API Keys', 'learnpress' ); ?></h2> | |
| 85 | + <input type="hidden" name="page" value="learn-press-settings" /> | |
| 86 | + <input type="hidden" name="tab" value="advanced" /> | |
| 87 | + <input type="hidden" name="section" value="mcp" /> | |
| 88 | + <?php wp_nonce_field( 'lp_mcp_bulk_revoke_action', 'lp_mcp_bulk_revoke_nonce' ); ?> | |
| 89 | + <?php $table->search_box( __( 'Search keys', 'learnpress' ), 'lp-mcp-keys-search' ); ?> | |
| 90 | + <?php $table->display(); ?> | |
| 91 | + </div> | |
| 92 | +</div> | |