'string', 'sanitize_callback' => 'lexiscript_sanitize_site_key', 'default' => '', ) ); } add_action( 'admin_init', 'lexiscript_register_settings' ); /** * Site keys are opaque identifiers, not free text. * * Restricted to the character set the control plane issues. Anything else is rejected rather * than escaped, because a key containing something exotic is a mistake or an attack, never a * real key, and failing loudly beats quietly serving a broken widget. */ function lexiscript_sanitize_site_key( $value ) { $value = is_string( $value ) ? trim( $value ) : ''; if ( '' === $value ) { return ''; } if ( ! preg_match( '/^[A-Za-z0-9_-]{8,128}$/', $value ) ) { add_settings_error( LEXISCRIPT_OPTION_KEY, 'lexiscript_bad_key', __( 'That does not look like a Lexiscript site key. Copy it from your website\'s page in the Lexiscript dashboard.', 'lexiscript' ), 'error' ); return lexiscript_site_key(); // Keep whatever was working before. } return $value; } /** The page itself. */ function lexiscript_render_settings_page() { if ( ! current_user_can( 'manage_options' ) ) { return; } $key = lexiscript_site_key(); $snippet = lexiscript_script_url(); ?>
jaytechkenya.com/lexiscript' ), array( 'a' => array( 'href' => array(), 'target' => array(), 'rel' => array(), ), ) ); ?>
' ); /* phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript -- Escaped text shown to the administrator, not a script. */ ?>
' . esc_html__( 'terms of service', 'lexiscript' ) . '', '' . esc_html__( 'privacy policy', 'lexiscript' ) . '' ), array( 'a' => array( 'href' => array(), 'target' => array(), 'rel' => array(), ), ) ); ?>