'string', 'sanitize_callback' => 'convertlyft_sanitize_key', 'default' => '', ) ); add_settings_section( 'convertlyft_main', '', '__return_false', 'convertlyft' ); add_settings_field( CONVERTLYFT_OPTION, esc_html__( 'Site key', 'convertlyft' ), 'convertlyft_render_key_field', 'convertlyft', 'convertlyft_main', array( 'label_for' => CONVERTLYFT_OPTION ) ); } add_action( 'admin_init', 'convertlyft_register_settings' ); /** * Render the site key input. */ function convertlyft_render_key_field() { printf( '', esc_attr( CONVERTLYFT_OPTION ), esc_attr( get_option( CONVERTLYFT_OPTION, '' ) ) ); echo '
'; printf( /* translators: %s: link to the Convertlyft sign-in page. */ esc_html__( 'Your site key starts with pk_. Find it in the install snippet in your %s workspace. Leave the field empty to remove the tag.', 'convertlyft' ), '' . esc_html__( 'Convertlyft', 'convertlyft' ) . '' ); echo '
'; } /** * Add the page under Settings. */ function convertlyft_add_settings_page() { add_options_page( esc_html__( 'Convertlyft', 'convertlyft' ), esc_html__( 'Convertlyft', 'convertlyft' ), 'manage_options', 'convertlyft', 'convertlyft_render_settings_page' ); } add_action( 'admin_menu', 'convertlyft_add_settings_page' ); /** * Render the settings page. settings_fields() prints the nonce; options.php checks it and manage_options. */ function convertlyft_render_settings_page() { if ( ! current_user_can( 'manage_options' ) ) { return; } $key = convertlyft_get_key(); ?>