Put a Discounts card on the shared Nolimit dashboard
The dashboard showed Cache, Security and Assistant and not this plugin. Being
absent from the dashboard is a different failure from being absent from the
menu, and Kristian hit them in that order — so each now has its own assertion
rather than one standing in for the other.
The card registers on wpmgr_dashboard_cards with the counts this plugin exists
to report: groups, and addresses currently receiving a discount.
Cached for five minutes. The contract says implementations must not measure
anything in that filter, because it runs on an admin page load and a slow card
makes somebody else's dashboard slow in a way they cannot attribute to us. Two
COUNT(*) on small indexed tables is the most this may cost, and the dashboard
is a page people leave open.
Status is warn rather than fail when nothing is configured: a shop that has
installed this and not set it up yet is unfinished, not broken. Reserving red
for actual breakage is what keeps red worth reading.
Two assertions, proven red by removing the add_filter:
FAIL this plugin puts a card on the shared dashboard — 0 card(s) registered
FAIL and it carries this plugin colour, not WooCommerce purple
— expected '#1a7a52', got NULL
The colour is matched against the literal, not against a constant. The shared
file renders whatever colour it is handed, so a card asserting its own constant
would agree with itself after somebody put WooCommerce purple back — the same
self-agreeing shape as the REST namespace assertion.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
370cf30979
commit
bf4b429014
@@ -287,6 +287,33 @@ wc_edm_ok(
|
||||
'it is not in the is_admin() branch of includes(), so nothing would define wpmgr_ensure_menu()'
|
||||
);
|
||||
|
||||
// The card on the shared dashboard. Absent from it is a different failure from
|
||||
// absent from the menu, and Kristian hit both in turn: the menu entry missing,
|
||||
// then the card missing once the entry was there.
|
||||
$wc_edm_cards = apply_filters( 'wpmgr_dashboard_cards', array() );
|
||||
$wc_edm_mine = array_values(
|
||||
array_filter(
|
||||
$wc_edm_cards,
|
||||
static function ( $card ) {
|
||||
return isset( $card['url'] ) && false !== strpos( $card['url'], WC_EDM_Admin::PAGE_SLUG );
|
||||
}
|
||||
)
|
||||
);
|
||||
wc_edm_ok(
|
||||
'this plugin puts a card on the shared dashboard',
|
||||
1 === count( $wc_edm_mine ),
|
||||
count( $wc_edm_cards ) . ' card(s) registered in total'
|
||||
);
|
||||
|
||||
// Matched against the literal rather than the constant: the shared file
|
||||
// renders any colour it is handed, so a card asserting its own constant would
|
||||
// agree with itself after somebody put WooCommerce purple back.
|
||||
wc_edm_is(
|
||||
'and it carries this plugin colour, not WooCommerce purple',
|
||||
'#1a7a52',
|
||||
isset( $wc_edm_mine[0]['colour'] ) ? $wc_edm_mine[0]['colour'] : null
|
||||
);
|
||||
|
||||
// includes/shared-menu.php is byte-identical in all five plugins, and which
|
||||
// copy a site loads is decided by activation order. Editing it here would make
|
||||
// a site with three of five updated show one label or another depending on who
|
||||
|
||||
Reference in New Issue
Block a user