Rename to Nolimit Discounts and move the page under the shared menu

Kristian could not find this plugin in the Nolimit menu, and it still called
itself WooCommerce Email Discount Manager. Both are the display side of the
family rename; neither touches the installed folder.

Plugin Name is now "Nolimit Discounts". The folder, the text domain, the option
prefix and the three tables are deliberately unchanged: WordPress identifies a
plugin as <folder>/<file>, so renaming the folder would not move the
installation on the live shop — it would put a second copy beside it and leave
the old one active. That is a migration with a shim, and it is Kristian's call
rather than a side effect of a label change.

includes/shared-menu.php added, byte-identical to the family copy
(f4862d5c…c63185), and the page moved from the WooCommerce submenu to the
shared parent. The page slug is unchanged, so admin.php?page=… still resolves
and an existing bookmark keeps working — moving a page between parents does not
move its URL.

The label is claimed through the wpmgr_menu_title filter from this plugin's own
bootstrap, NOT by editing the shared file. Which copy of that file a site loads
is decided by activation order, and PHP cannot un-declare a function, so the
first copy wins for the whole request: editing it would make a site with three
of five plugins updated show "Manager" or "Nolimit" depending on who booted
first, and change its mind when a plugin is deactivated. The filter is
idempotent and a plugin still on an older build changes nothing.

The filter is registered before the WooCommerce gate, for the same reason the
updater is: the shared menu's label must not depend on whether this particular
plugin got past a check.

Two assertions, both proven red first. The label is asserted through the filter
rather than by reading the menu, because the menu is only built in an admin
request and the smoke tests run under WP-CLI. And the shared file's sha256 is
asserted, so editing it goes red here rather than going strange on a shop —
appending one comment line produced:

  FAIL  and the shared menu file is the family copy, unedited
        — expected 'f4862d5c…', got '45df6b55…'

Also caught in passing by the kit, working exactly as intended: the new
shared-menu.php was untracked, and "every file the plugin loads is a file the
release contains" failed rather than shipping a zip without it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kristianwind
2026-09-17 22:05:19 +02:00
co-authored by Claude Opus 5
parent 23d826530b
commit 9f19688900
4 changed files with 293 additions and 5 deletions
+28 -1
View File
@@ -1,6 +1,6 @@
<?php
/**
* Plugin Name: WooCommerce Email Discount Manager
* Plugin Name: Nolimit Discounts
* Plugin URI: https://gitea.nolimit.dk/kw/woo-discount-manager
* Update URI: https://gitea.nolimit.dk/kw/woo-discount-manager
* Description: Apply discounts and show/hide shipping methods based on the customer's email address (full address, domain or partial match).
@@ -123,6 +123,18 @@ final class WC_Email_Discount_Manager {
_doing_it_wrong( __FUNCTION__, 'Unserializing is not allowed.', '1.0.0' );
}
/**
* The label on the shared parent menu all five plugins register under.
*
* A brand name, so it is returned as a literal rather than run through
* __(): translating it would give the product a different name in Danish.
*
* @return string
*/
public function shared_menu_title() {
return 'Nolimit';
}
/**
* Bootstrap once all plugins are loaded.
*/
@@ -137,6 +149,20 @@ final class WC_Email_Discount_Manager {
$this->updater = new WC_EDM_Updater();
}
// Also deliberately before the WooCommerce check, and for the same
// reason as the updater above: the shared parent menu is registered by
// whichever of the five plugins boots first, and its label must not
// depend on whether THIS plugin got past a gate.
//
// Registered here rather than by editing includes/shared-menu.php:
// that file is byte-identical in all five, and which copy a site loads
// is decided by activation order. Changing it there would make a site
// with three of five updated show "Manager" or "Nolimit" depending on
// who booted first, and change its mind when a plugin is deactivated.
// The filter is idempotent, so a plugin still on the old build changes
// nothing.
add_filter( 'wpmgr_menu_title', array( $this, 'shared_menu_title' ) );
if ( ! class_exists( 'WooCommerce' ) ) {
add_action( 'admin_notices', array( $this, 'woocommerce_missing_notice' ) );
return;
@@ -208,6 +234,7 @@ final class WC_Email_Discount_Manager {
$files = array_merge(
$files,
array(
'includes/shared-menu.php',
'includes/class-admin.php',
'includes/class-admin-groups.php',
'includes/class-admin-emails.php',