register_settings( aiou()->settings() ); ( new Feature() )->register(); } /** * Register the "Author Pages" section. * * @param SettingsRegistry $settings The settings registry. * @return void */ private function register_settings( SettingsRegistry $settings ): void { $settings->add_section( 'security', 'author_pages', __( 'Author Pages', 'all-in-one-utilities' ), __( 'Author archive pages (e.g. /author/jane/) list everything one user has published. Most sites, especially single-author ones, don\'t need them -- and the URL itself reveals a valid username.', 'all-in-one-utilities' ), 30 ); $settings->add_field( 'security', 'author_pages', new Field( id: 'enabled', label: __( 'Disable author pages', 'all-in-one-utilities' ), type: 'checkbox', default: 0, args: array( 'toggle_label' => __( 'Stop showing author archive pages', 'all-in-one-utilities' ) ), priority: 10 ) ); $settings->add_field( 'security', 'author_pages', new Field( id: 'response', label: __( 'Visitors get', 'all-in-one-utilities' ), type: 'select', default: 'redirect', args: array( 'choices' => array( 'redirect' => __( 'A redirect to the page below', 'all-in-one-utilities' ), '404' => __( 'A "page not found" (404) error', 'all-in-one-utilities' ), ), 'depends_on' => 'enabled', ), doc: new Doc( title: __( 'Redirect or 404', 'all-in-one-utilities' ), short: __( 'A 404 tells visitors and search engines the page doesn\'t exist. A redirect sends them somewhere useful instead. "Redirect to" and "Redirect type" only apply to the redirect.', 'all-in-one-utilities' ) ), priority: 15 ) ); $settings->add_field( 'security', 'author_pages', new Field( id: 'destination_page', label: __( 'Redirect to', 'all-in-one-utilities' ), type: 'page', default: 0, args: array( 'none_label' => __( 'Homepage', 'all-in-one-utilities' ), 'depends_on' => 'enabled', ), priority: 20 ) ); $settings->add_field( 'security', 'author_pages', new Field( id: 'status_code', label: __( 'Redirect type', 'all-in-one-utilities' ), type: 'select', default: '301', args: array( 'choices' => array( '301' => __( '301 (permanent)', 'all-in-one-utilities' ), '307' => __( '307 (temporary)', 'all-in-one-utilities' ), ), 'depends_on' => 'enabled', ), doc: new Doc( title: __( 'Redirect type', 'all-in-one-utilities' ), short: __( 'Use 307 while you\'re still deciding -- search engines treat a 301 as permanent and may update their index accordingly.', 'all-in-one-utilities' ) ), priority: 30 ) ); $settings->add_field( 'security', 'author_pages', new Field( id: 'admin_only', label: __( 'Limit to administrators', 'all-in-one-utilities' ), type: 'checkbox', default: 0, args: array( 'toggle_label' => __( 'Only disable the author page for users with the Administrator role', 'all-in-one-utilities' ), 'depends_on' => 'enabled', ), priority: 40 ) ); $settings->add_field( 'security', 'author_pages', new Field( id: 'redirect_invalid', label: __( 'Also handle invalid requests', 'all-in-one-utilities' ), type: 'checkbox', default: 0, args: array( 'toggle_label' => __( 'Treat requests for an author that doesn\'t exist the same way', 'all-in-one-utilities' ), 'depends_on' => 'enabled', ), doc: new Doc( title: __( 'Why this matters', 'all-in-one-utilities' ), short: __( 'Without this, an invalid author ID 404s while a valid (but disabled) one redirects -- letting an attacker tell real user IDs apart from made-up ones just by watching which response they get.', 'all-in-one-utilities' ) ), priority: 50 ) ); $settings->add_field( 'security', 'author_pages', new Field( id: 'hide_author_link', label: __( 'Hide author links', 'all-in-one-utilities' ), type: 'checkbox', default: 0, args: array( 'toggle_label' => __( 'Blank out the author link URL used in post bylines and archives', 'all-in-one-utilities' ), 'depends_on' => 'enabled', ), doc: new Doc( title: __( 'Hide author links', 'all-in-one-utilities' ), short: __( 'Best-effort: this empties the URL author links point to, but whether a theme still renders a (now empty) link element depends on the theme itself.', 'all-in-one-utilities' ) ), priority: 60 ) ); } }