'welcome_panel', 'dashboard_quick_press' => 'dashboard_quick_press', 'dashboard_primary' => 'dashboard_primary', 'dashboard_activity' => 'dashboard_activity', 'dashboard_right_now' => 'dashboard_right_now', 'dashboard_site_health' => 'dashboard_site_health_status', ]; foreach ( $hidden as $widget_id ) { if ( 'welcome_panel' === $widget_id ) { remove_action( 'welcome_panel', 'wp_welcome_panel' ); continue; } $meta_id = $widget_map[ $widget_id ] ?? $widget_id; remove_meta_box( $meta_id, 'dashboard', 'normal' ); remove_meta_box( $meta_id, 'dashboard', 'side' ); } // Add custom widget. $title = self::$settings['custom_widget_title'] ?? ''; $content = self::$settings['custom_widget_content'] ?? ''; if ( $title && $content ) { wp_add_dashboard_widget( 'agoadmin_custom_widget', esc_html( $title ), function () use ( $content ) { echo wp_kses_post( $content ); } ); } } /* ───── Footer Text ───── */ public static function footer_text(): string { return wp_kses_post( self::$settings['footer_text'] ); } /* ───── Login Redirect ───── */ /** * @param string $redirect_to * @param string $requested_redirect_to * @param \WP_User|\WP_Error $user */ public static function login_redirect( $redirect_to, $requested_redirect_to, $user ): string { // Only redirect if no explicit redirect was requested. if ( $requested_redirect_to ) { return $redirect_to; } return esc_url_raw( self::$settings['login_redirect_url'] ); } /* ───── Admin Bar ───── */ public static function maybe_hide_admin_bar( bool $show ): bool { $user = wp_get_current_user(); if ( ! $user || ! $user->exists() ) { return $show; } $hide_roles = self::$settings['hide_admin_bar_roles']; foreach ( $user->roles as $role ) { if ( in_array( $role, $hide_roles, true ) ) { return false; } } return $show; } }