', esc_attr( $type ), esc_attr( $option_name ), esc_attr( $option_name ), esc_attr( $option_value ), esc_attr( $placeholder ) ); if ( false !== $description ) { echo '
' . esc_html( $description ) . '
'; } } /** * Displays a select/drop-down input field on the options page * * @param string $option_name the name of the plugin option. * @param string $description description to display under option. * @return void */ public function options_page_select_input_action( $option_name, $description = false ) { $option_value = get_option( $option_name, '' ); printf( '' ); if ( false !== $description ) { echo '' . esc_html( $description ) . '
'; } } /** * Sets up actions for plugin settings * * @return void */ public function register_settings_action() { add_settings_section( 'ahjwtauth-sign-in-widget-options-section', '', null, 'ahjwtauth-sign-in-widget', ); register_setting( 'ahjwtauth-sign-in-widget', 'ahjwtauth-private-secret', array( 'type' => 'string', 'show_in_rest' => false, ), ); register_setting( 'ahjwtauth-sign-in-widget', 'ahjwtauth-jwks-url', array( 'type' => 'string', 'show_in_rest' => true, ), ); register_setting( 'ahjwtauth-sign-in-widget', 'ahjwtauth-jwt-header', array( 'type' => 'string', 'show_in_rest' => true, 'default' => 'Authorization', ), ); add_settings_field( 'ahjwtauth-private-secret', 'JWT Private Secret', function() { $this->options_page_text_input_action( 'ahjwtauth-private-secret', 'text', __( 'Paste your JWT private secret here.', 'ah-jwt-auth' ), __( 'This secret is used for verifying the token (use this field or the "JWKS URL", not both).', 'ah-jwt-auth' ), ); }, 'ahjwtauth-sign-in-widget', 'ahjwtauth-sign-in-widget-options-section' ); add_settings_field( 'ahjwtauth-jwks-url', 'JWKS URL', function() { $this->options_page_text_input_action( 'ahjwtauth-jwks-url', 'text', __( 'Enter the JWKS URL to validate the JWT.', 'ah-jwt-auth' ), __( 'The retreived JWKS is used for verifying the token (use this field or the "JWT Private Secret", not both)', 'ah-jwt-auth' ), ); }, 'ahjwtauth-sign-in-widget', 'ahjwtauth-sign-in-widget-options-section', ); add_settings_field( 'ahjwtauth-jwt-header', 'JWT Header', function() { $this->options_page_text_input_action( 'ahjwtauth-jwt-header', 'text', __( 'Enter the HTTP header that contains the JWT.', 'ah-jwt-auth' ), __( 'The JWT will be retrieved from the specified HTTP header. This defaults to the "Authorization" header.', 'ah-jwt-auth' ), ); }, 'ahjwtauth-sign-in-widget', 'ahjwtauth-sign-in-widget-options-section', ); add_settings_field( 'ahjwtauth-user-role', 'Default User Role', function() { $this->options_page_select_input_action( 'ahjwtauth-user-role', __( 'Select the role for and auto-created user if a role claim is not found in the JWT.', 'ah-jwt-auth' ), ); }, 'ahjwtauth-sign-in-widget', 'ahjwtauth-sign-in-widget-options-section', ); } }