register_settings( aiou()->settings() ); ( new Feature() )->register(); } /** * Register the "Random Content" section. * * @param SettingsRegistry $settings The settings registry. * @return void */ private function register_settings( SettingsRegistry $settings ): void { $settings->add_section( self::TAB, self::SECTION, __( 'Random Content', 'all-in-one-utilities' ), __( 'WordPress 7.2 adds /random/ addresses that send visitors to a random post, such as /random/ and /random/category/news/, and the same for ?random on any archive or search. Turn them off if you don\'t want them.', 'all-in-one-utilities' ), 75 ); $settings->add_field( self::TAB, self::SECTION, new Field( id: 'enabled', label: __( 'Disable random content', 'all-in-one-utilities' ), type: 'checkbox', default: 0, args: array( 'toggle_label' => __( 'Turn off /random/ addresses and ?random links', 'all-in-one-utilities' ) ), doc: new Doc( title: __( 'What changes', 'all-in-one-utilities' ), short: __( '/random/ addresses stop redirecting: they show "page not found", or your own page if you have one with that address. On archives and searches, ?random is ignored and the normal page is shown. Your posts keep their usual addresses.', 'all-in-one-utilities' ), detailed: __( 'This only works on WordPress 7.2 and later, the version that added random content. You can switch it on earlier, ahead of the update. WordPress rebuilds its permalinks by itself after you save, so you don\'t need to resave Settings → Permalinks. Switching the setting off, or deactivating the plugin, brings back WordPress\'s normal behavior.', 'all-in-one-utilities' ) ), priority: 10 ) ); $settings->add_field( self::TAB, self::SECTION, new Field( id: 'allow', label: __( 'Keep random links for', 'all-in-one-utilities' ), type: 'checklist', default: array(), args: array( 'choices' => static fn (): array => Archives::choices(), 'empty' => __( 'No archives can use random links on this site.', 'all-in-one-utilities' ), 'description' => __( 'Optional. Random links keep working on the archives you tick, for example /random/category/news/ and /category/news/?random. The site-wide /random/ and author archives stay off.', 'all-in-one-utilities' ), 'depends_on' => 'enabled', ), doc: new Doc( title: __( 'Why author archives stay off', 'all-in-one-utilities' ), short: __( '/random/author/name/ only redirects for real authors, so it would reveal valid usernames even when author pages are turned off.', 'all-in-one-utilities' ) ), priority: 20 ) ); $settings->add_field( self::TAB, self::SECTION, new Field( id: 'terms', label: __( 'Only these terms', 'all-in-one-utilities' ), type: 'textarea', default: '', args: array( 'description' => __( 'Optional. One category, tag or term slug per line, such as news. When filled, only these terms of the ticked taxonomies keep random links. A subcategory needs its own line. Post type archives are not affected.', 'all-in-one-utilities' ), 'depends_on' => 'enabled', 'rows' => 4, ), priority: 30 ) ); } }