Api_Credentials::register_settings_section( $suffix, $screen )
Summary
No summary available.Return
(void)
Source
File: src/BigCommerce/Settings/Sections/Api_Credentials.php
public function register_settings_section( $suffix, $screen ) { add_settings_section( self::NAME, __( 'API Credentials', 'bigcommerce' ), function ( $section ) { do_action( 'bigcommerce/settings/render/credentials', $section ); }, $screen ); $options = [ self::OPTION_STORE_URL => [ 'label' => __( 'Base API Path', 'bigcommerce' ), 'label_for' => 'field-' . self::OPTION_STORE_URL, 'description' => __( 'The API Path for your BigCommerce store. E.g., https://api.bigcommerce.com/stores/abc9defghi/v3/', 'bigcommerce' ), ], self::OPTION_CLIENT_ID => [ 'label' => __( 'Client ID', 'bigcommerce' ), 'label_for' => 'field-' . self::OPTION_CLIENT_ID, 'description' => __( 'The Client ID provided for your API account. E.g., abcdefg24hijk6lmno8pqrs1tu3vwxyz', 'bigcommerce' ), 'type' => 'password', ], self::OPTION_CLIENT_SECRET => [ 'label' => __( 'Client Secret', 'bigcommerce' ), 'label_for' => 'field-' . self::OPTION_CLIENT_SECRET, 'description' => __( 'The Client Secret provided for your API account. E.g., 0bcdefg24hijk6lmno8pqrs1tu3vw5x', 'bigcommerce' ), 'type' => 'password', ], self::OPTION_ACCESS_TOKEN => [ 'label' => __( 'Access Token', 'bigcommerce' ), 'label_for' => 'field-' . self::OPTION_ACCESS_TOKEN, 'description' => __( 'The Access Token provided for your API account. E.g., ab24cdef68gh13ijkl5mn7opqrst9u2v', 'bigcommerce' ), 'type' => 'password', ], ]; foreach ( $options as $key => $args ) { $args = wp_parse_args( $args, [ 'option' => $key, 'label' => '', 'type' => 'text', 'autocomplete' => 'off', ] ); add_settings_field( $key, esc_html( $args[ 'label' ] ), [ $this, 'render_field', ], $screen, self::NAME, $args ); $disabled = $this->disabled_message( $key );; if ( ! $disabled ) { // prevents clearing out value in DB when constant is set register_setting( $screen, $key ); } } }