migrate_clean_dashboard(); $settings = aiou()->settings(); $this->register_dashboard( $settings ); $this->register_footer( $settings ); $this->register_version( $settings ); $this->register_admin_bar( $settings ); ( new DashboardWidgets() )->register(); ( new Feature() )->register(); } /** * Dashboard section. * * @param SettingsRegistry $settings The settings registry. * @return void */ private function register_dashboard( SettingsRegistry $settings ): void { $settings->add_section( self::TAB, 'dashboard', __( 'Dashboard', 'all-in-one-utilities' ), __( 'Choose which widgets the Dashboard shows, for everyone.', 'all-in-one-utilities' ), 20 ); $settings->add_field( self::TAB, 'dashboard', new Field( id: 'hide_widgets', label: __( 'Hide these widgets', 'all-in-one-utilities' ), type: 'checklist', default: array(), args: array( 'choices' => DashboardWidgets::known(), 'description' => __( 'Widgets added by other plugins appear here after the Dashboard has been opened once.', 'all-in-one-utilities' ), ), doc: new Doc( title: __( 'Hiding Dashboard widgets', 'all-in-one-utilities' ), short: __( 'Hidden widgets are removed for every user, and are no longer offered under Screen Options.', 'all-in-one-utilities' ), detailed: __( 'Each user can already hide widgets for themselves under Screen Options; this hides them for everyone. Plugins usually add their widgets only when the Dashboard is built, so open the Dashboard once after installing a plugin to list its widgets here.', 'all-in-one-utilities' ) ), priority: 10 ) ); $settings->add_field( self::TAB, 'dashboard', new Field( id: 'hide_welcome_panel', label: __( 'Welcome panel', 'all-in-one-utilities' ), type: 'checkbox', default: 0, args: array( 'toggle_label' => __( 'Hide the "Welcome to WordPress!" panel', 'all-in-one-utilities' ) ), priority: 20 ) ); } /** * Admin Footer section. * * @param SettingsRegistry $settings The settings registry. * @return void */ private function register_footer( SettingsRegistry $settings ): void { $settings->add_section( self::TAB, 'admin_footer', __( 'Admin Footer', 'all-in-one-utilities' ), __( 'Replace "Thank you for creating with WordPress." at the bottom of every admin screen.', 'all-in-one-utilities' ), 30 ); $settings->add_field( self::TAB, 'admin_footer', new Field( id: 'custom_footer', label: __( 'Custom footer text', 'all-in-one-utilities' ), type: 'checkbox', default: 0, args: array( 'toggle_label' => __( 'Replace the footer text', 'all-in-one-utilities' ) ), priority: 10 ) ); $settings->add_field( self::TAB, 'admin_footer', new Field( id: 'footer_text', label: __( 'Footer text', 'all-in-one-utilities' ), type: 'textarea', default: '', args: array( 'rows' => 2, 'depends_on' => 'custom_footer', 'description' => __( 'Links and basic HTML are allowed. Use {site_name}, {site_url}, and {year}. Leave empty to show no text at all.', 'all-in-one-utilities' ), ), sanitize: static fn( $value ): string => wp_kses_post( trim( (string) $value ) ), priority: 20 ) ); } /** * WordPress Version section. * * @param SettingsRegistry $settings The settings registry. * @return void */ private function register_version( SettingsRegistry $settings ): void { $settings->add_section( self::TAB, 'wp_version', __( 'WordPress Version', 'all-in-one-utilities' ), __( 'Stop showing which WordPress version the site runs.', 'all-in-one-utilities' ), 40 ); $settings->add_field( self::TAB, 'wp_version', new Field( id: 'hide_wp_version', label: __( 'Hide WordPress version', 'all-in-one-utilities' ), type: 'checkbox', default: 0, args: array( 'toggle_label' => __( 'Hide the WordPress version from users and visitors', 'all-in-one-utilities' ) ), doc: new Doc( title: __( 'Hiding the WordPress version', 'all-in-one-utilities' ), short: __( 'Removes the version from the admin footer and the At a Glance widget, the generator tag in the page source and feeds, and core\'s script and style URLs.', 'all-in-one-utilities' ), detailed: __( 'Users who can update WordPress (administrators) still see the version and any update notice in wp-admin. In asset URLs the version is replaced with a short code that still changes with each WordPress update, so browsers keep fetching fresh files.', 'all-in-one-utilities' ) ), priority: 10 ) ); } /** * Toolbar section. * * @param SettingsRegistry $settings The settings registry. * @return void */ private function register_admin_bar( SettingsRegistry $settings ): void { $settings->add_section( self::TAB, 'admin_bar', __( 'Toolbar', 'all-in-one-utilities' ), __( 'The black bar shown above the site to logged-in users.', 'all-in-one-utilities' ), 50 ); $settings->add_field( self::TAB, 'admin_bar', new Field( id: 'hide_for_roles', label: __( 'Hide the toolbar for', 'all-in-one-utilities' ), type: 'checklist', default: array(), args: array( 'choices' => array_map( 'translate_user_role', Roles::all() ), 'description' => __( 'Users with any of these roles no longer see the toolbar when viewing the site. WordPress always shows it inside wp-admin.', 'all-in-one-utilities' ), ), priority: 10 ) ); } /** * Settings → Performance → Admin Experience used to have one "Clean * Dashboard" toggle that removed every core widget. Carry it over to * the per-widget choices here, once. * * @return void */ private function migrate_clean_dashboard(): void { $performance = get_option( 'aiou_settings_performance' ); if ( ! is_array( $performance ) || ! isset( $performance['admin_experience']['clean_dashboard'] ) ) { return; } $admin = get_option( 'aiou_settings_admin', array() ); $admin = is_array( $admin ) ? $admin : array(); if ( ! empty( $performance['admin_experience']['clean_dashboard'] ) && ! isset( $admin['dashboard'] ) ) { $admin['dashboard'] = array( 'hide_widgets' => array_keys( DashboardWidgets::core() ), 'hide_welcome_panel' => 1, ); update_option( 'aiou_settings_admin', $admin ); } unset( $performance['admin_experience']['clean_dashboard'] ); update_option( 'aiou_settings_performance', $performance ); } }