Skip to content

Extend "At a Glance" widget support to independent content blocks#12469

Open
himanshupathak95 wants to merge 2 commits into
WordPress:trunkfrom
himanshupathak95:fix/26571
Open

Extend "At a Glance" widget support to independent content blocks#12469
himanshupathak95 wants to merge 2 commits into
WordPress:trunkfrom
himanshupathak95:fix/26571

Conversation

@himanshupathak95

Copy link
Copy Markdown

Trac ticket: https://core.trac.wordpress.org/ticket/26571

This PR resolves long-standing extensibility limitations within the "At a Glance" dashboard widget. It introduces targeted, enhancements to the widget's render pipeline, enabling developers to natively style existing items and append entirely new structural lists.

  • Modified the $elements loop in wp_dashboard_right_now() (inside src/wp-admin/includes/dashboard.php) to accept an associative array structure with class and content keys.
  • Ensures strict backward compatibility by defaulting to plain string parsing for array elements containing just HTML strings.
  • Introduced a dedicated action hook immediately following the termination of the primary <ul>. This directly fulfills the ticket's secondary request to support "multiple lists," enabling developers to cleanly inject secondary lists or visual separators before the widget's metadata footer.

Screenshots

Before

Screenshot 2026-07-10 at 13 51 06

After

Screenshot 2026-07-10 at 13 51 37

Code Snippet Used -

add_filter( 'dashboard_glance_items', 'test_dashboard_glance_items_filter' );
function test_dashboard_glance_items_filter( $items ) {
	$items[] = '<a href="#">Custom Item Without Class</a>';
	return $items;
}

add_filter( 'dashboard_glance_items', 'test_dashboard_glance_items_hack' );
function test_dashboard_glance_items_hack( $items ) {
	$items[] = '</li><li class="custom-class-hack"><a href="#">Hacked Class Item</a>';
	return $items;
}

add_filter( 'dashboard_glance_items', 'test_dashboard_glance_items_array' );
function test_dashboard_glance_items_array( $items ) {
	$items[] = array(
		'class'   => 'new-custom-class',
		'content' => '<a href="#">New Array Class Item</a>',
	);
	return $items;
}

add_action( 'admin_head', 'test_dashboard_glance_items_css' );
function test_dashboard_glance_items_css() {
	echo '<style type="text/css">
		#dashboard_right_now .new-custom-class a:before {
			content: "\f348" !important; /* Dashicon dashicons-info */
			color: #0073aa;
		}
		#dashboard_right_now .new-custom-class {
			font-weight: bold;
		}
	</style>';
}

@himanshupathak95
himanshupathak95 marked this pull request as ready for review July 10, 2026 08:34
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props abcd95.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@himanshupathak95 himanshupathak95 changed the title Refactor "At a Glance" widget extensibility to support CSS classes and independent content blocks Extend "At a Glance" widget support to independent content blocks Jul 10, 2026
@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant