1.5.3: shared-menu 1.2.2, and run the glyph style instead of reading it
678f1f03 is withdrawn. It hard-coded the icon box at 36x34, and WordPress declares that parent three times with different sizes — 36x34 open, 35x30 folded, 34x30 under 960px — so a fixed number is correct in one state and 4px too tall in the two a laptop is usually in. cache-manager measured where the ink lands rather than where the box is and found it worse than that: the glyph moved from 2.5px above centre to 2.5px below in the folded states, the same error mirrored, in a state that had been nearly right. 1.2.2 removes the number entirely with width/height at 100%. 1.5.2 is already published with 678f1f03, so this tree shipped the withdrawn version. Checked before anything else, because a later candidate fatalled on every admin page with "Unknown format specifier": that file was never taken here, and the published 1.5.2 emits its stylesheet cleanly — verified by running sprintf over its format string rather than reading it. So the shop is cosmetically off in folded menus, not broken. New assertion, and it is the one this round is really about: the style function is INVOKED and its output captured, rather than the source being read. The fatal that prompted it survived three sessions reading the file, a clean php -l, a clean PHPCS, and two browsers agreeing about the CSS — because every one of those was fed the stylesheet by hand rather than through the printf that produces it. A literal per-cent must be doubled in a format string, and nothing that looks at the file can see that. Proven red with that exact fault rather than an arbitrary one: undoubling the per-cent gives "ValueError: Unknown format specifier ';'". Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
db5c5e33c8
commit
6a789349ec
+1
-1
@@ -4,7 +4,7 @@ Tags: woocommerce, discount, email, shipping, coupon
|
|||||||
Requires at least: 5.8
|
Requires at least: 5.8
|
||||||
Tested up to: 7.1
|
Tested up to: 7.1
|
||||||
Requires PHP: 7.4
|
Requires PHP: 7.4
|
||||||
Stable tag: 1.5.2
|
Stable tag: 1.5.3
|
||||||
WC requires at least: 6.0
|
WC requires at least: 6.0
|
||||||
WC tested up to: 11.1.0
|
WC tested up to: 11.1.0
|
||||||
License: GPLv2 or later
|
License: GPLv2 or later
|
||||||
|
|||||||
+6
-2
@@ -75,7 +75,11 @@ RELEASE_REPO=kw/nolimit-discounts-dist
|
|||||||
# The frozen hash is therefore a family-wide fact, not a local one, and taking
|
# The frozen hash is therefore a family-wide fact, not a local one, and taking
|
||||||
# a new one is something all six do in the same window.
|
# a new one is something all six do in the same window.
|
||||||
#
|
#
|
||||||
# 678f1f03 = contract 1.2.1: the glyph is centred with flex inside an explicit
|
# 471b0a2a = contract 1.2.2: the icon box is sized 100%/100% instead of a
|
||||||
|
# hardcoded 36x34. WordPress declares that parent three times and they
|
||||||
|
# disagree (36x34 open, 35x30 folded, 34x30 under 960px), so a fixed number is
|
||||||
|
# right in one state and wrong in the two a laptop is usually in.
|
||||||
|
# Withdrawn: 678f1f03 = 1.2.1: the glyph is centred with flex inside an explicit
|
||||||
# 36x34 box instead of inheriting WordPress's 7px padding, which made the
|
# 36x34 box instead of inheriting WordPress's 7px padding, which made the
|
||||||
# pseudo-element 42px tall inside a 34px parent and pushed the sign above
|
# pseudo-element 42px tall inside a 34px parent and pushed the sign above
|
||||||
# centre. Kristian reported it from the live shop.
|
# centre. Kristian reported it from the live shop.
|
||||||
@@ -87,4 +91,4 @@ RELEASE_REPO=kw/nolimit-discounts-dist
|
|||||||
# backslashes, hex digits and spaces, so there is nothing left to leave the
|
# backslashes, hex digits and spaces, so there is nothing left to leave the
|
||||||
# string with. Verified here against seven hostile inputs.
|
# string with. Verified here against seven hostile inputs.
|
||||||
# Earlier frozen hashes: 184cebdc = 1.1.0, f4862d5c = 1.0.0.
|
# Earlier frozen hashes: 184cebdc = 1.1.0, f4862d5c = 1.0.0.
|
||||||
WPMGR_MENU_SHA=678f1f0368fcc781ce34c0289f6470a6bb0491bc32c0598e859c7ceba66e5e2a
|
WPMGR_MENU_SHA=471b0a2aab47b6b7f8d839ac8b12d60637bbe2c07df86f7e40089c677fbab3cc
|
||||||
|
|||||||
+36
-14
@@ -69,7 +69,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( ! defined( 'WPMGR_MENU_VERSION' ) ) {
|
if ( ! defined( 'WPMGR_MENU_VERSION' ) ) {
|
||||||
define( 'WPMGR_MENU_VERSION', '1.2.1' );
|
define( 'WPMGR_MENU_VERSION', '1.2.2' );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! defined( 'WPMGR_MENU_SLUG' ) ) {
|
if ( ! defined( 'WPMGR_MENU_SLUG' ) ) {
|
||||||
@@ -164,19 +164,41 @@ if ( ! function_exists( 'wpmgr_ensure_menu' ) ) {
|
|||||||
* 🔴 The box is WordPress's own, measured rather than guessed, and the
|
* 🔴 The box is WordPress's own, measured rather than guessed, and the
|
||||||
* glyph is centred in it geometrically rather than nudged.
|
* glyph is centred in it geometrically rather than nudged.
|
||||||
*
|
*
|
||||||
* wp-admin/css/admin-menu.css sets `#adminmenu div.wp-menu-image` to
|
* wp-admin/css/admin-menu.css sets `div.wp-menu-image:before` to
|
||||||
* 36x34, and `div.wp-menu-image:before` to `padding: 7px 0` — which is
|
* `padding: 7px 0` — exactly 7 + 20 + 7 for a 20px dashicon on
|
||||||
* exactly 7 + 20 + 7 for a 20px dashicon on `line-height: 1`. The first
|
* `line-height: 1` in a 34px box. The first version of this rule set
|
||||||
* version of this rule set `line-height: 1.4` and inherited that padding,
|
* `line-height: 1.4` and inherited that padding, making the line box 28px
|
||||||
* making the line box 28px and the whole pseudo-element 42px inside a 34px
|
* and the whole pseudo-element 42px inside a 34px parent. Kristian
|
||||||
* parent. Kristian reported the result: the glyph sitting above centre.
|
* reported the result: the glyph sitting above centre.
|
||||||
*
|
*
|
||||||
* So: reproduce the 36x34 box, drop the padding that only existed to
|
* So: drop the padding that only existed to position a 20px line, and
|
||||||
* position a 20px line inside it, and centre with flex. That matters more
|
* centre with flex. That matters more for an arbitrary glyph than for a
|
||||||
* for an arbitrary glyph than for a dashicon — U+221E sits on the maths
|
* dashicon — U+221E sits on the maths axis rather than filling its em box,
|
||||||
* axis rather than filling its em box, so any rule that positions by
|
* so any rule that positions by line-height and padding is positioning the
|
||||||
* line-height and padding is positioning the box and hoping about the
|
* box and hoping about the glyph. `align-items: center` centres what is
|
||||||
* glyph. `align-items: center` centres what is actually drawn.
|
* actually drawn, which is also what keeps working if anyone returns
|
||||||
|
* something else from `wpmgr_menu_glyph`.
|
||||||
|
*
|
||||||
|
* 🔴 `100%%`, not `100%`. This is a printf format string, so a literal
|
||||||
|
* per-cent sign has to be doubled — and the first version of the
|
||||||
|
* percentage fix did not, which is a **fatal on every admin page**:
|
||||||
|
* "Uncaught ValueError: Unknown format specifier". Three sessions agreed
|
||||||
|
* on that file after reading it, linting it and running PHPCS over it, and
|
||||||
|
* all three are blind to this: the syntax is valid and the standard has
|
||||||
|
* nothing to say. Only running the function finds it, and it was the site
|
||||||
|
* test that did. The fixed-pixel version could not have had this fault,
|
||||||
|
* so it arrived with the improvement.
|
||||||
|
*
|
||||||
|
* 🔴 The size is `100%`, not the 36x34 the desktop menu happens to be.
|
||||||
|
* That stylesheet declares the parent THREE times and they disagree:
|
||||||
|
* `#adminmenu div.wp-menu-image` is 36x34, `.folded #adminmenu
|
||||||
|
* div.wp-menu-image` is 35x30, and under `@media (max-width: 960px)`
|
||||||
|
* `.auto-fold #adminmenu div.wp-menu-image` is 34x30. A pseudo-element
|
||||||
|
* fixed at 36x34 is therefore correct on a wide screen with the menu open
|
||||||
|
* and 4px too tall in both of the other states — which are the states a
|
||||||
|
* laptop is in. Percentages resolve against whichever parent is in force,
|
||||||
|
* so there is no number here to be right about. Measured by reading that
|
||||||
|
* stylesheet, not by eye.
|
||||||
*/
|
*/
|
||||||
function wpmgr_menu_glyph_style() {
|
function wpmgr_menu_glyph_style() {
|
||||||
$glyph = apply_filters( 'wpmgr_menu_glyph', '∞' );
|
$glyph = apply_filters( 'wpmgr_menu_glyph', '∞' );
|
||||||
@@ -187,7 +209,7 @@ if ( ! function_exists( 'wpmgr_ensure_menu' ) ) {
|
|||||||
|
|
||||||
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped -- the slug is reduced to [a-z0-9_-] and the glyph to CSS numeric escapes; both are escaped for the context they are printed in, which is CSS rather than HTML.
|
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped -- the slug is reduced to [a-z0-9_-] and the glyph to CSS numeric escapes; both are escaped for the context they are printed in, which is CSS rather than HTML.
|
||||||
printf(
|
printf(
|
||||||
'<style>#adminmenu .toplevel_page_%1$s .wp-menu-image::before{content:"%2$s";font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;font-size:20px;font-weight:400;display:flex;align-items:center;justify-content:center;width:36px;height:34px;padding:0;line-height:1}</style>',
|
'<style>#adminmenu .toplevel_page_%1$s .wp-menu-image::before{content:"%2$s";font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;font-size:20px;font-weight:400;display:flex;align-items:center;justify-content:center;width:100%%;height:100%%;padding:0;line-height:1}</style>',
|
||||||
preg_replace( '/[^a-z0-9_-]/', '', strtolower( WPMGR_MENU_SLUG ) ),
|
preg_replace( '/[^a-z0-9_-]/', '', strtolower( WPMGR_MENU_SLUG ) ),
|
||||||
wpmgr_css_escape( $glyph )
|
wpmgr_css_escape( $glyph )
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -317,6 +317,38 @@ wc_edm_is(
|
|||||||
isset( $wc_edm_mine[0]['colour'] ) ? $wc_edm_mine[0]['colour'] : null
|
isset( $wc_edm_mine[0]['colour'] ) ? $wc_edm_mine[0]['colour'] : null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 🔴 The style function is INVOKED, not read. A version of this file shipped
|
||||||
|
// with `width:100%` inside a printf format string, where a literal per-cent
|
||||||
|
// must be doubled — an uncaught ValueError on every admin page. Three sessions
|
||||||
|
// read it, php -l was clean, PHPCS was clean, and two browsers agreed about
|
||||||
|
// the CSS, because all of them were fed the stylesheet by hand rather than
|
||||||
|
// through the PHP that produces it. Only running it finds this.
|
||||||
|
if ( function_exists( 'wpmgr_menu_glyph_style' ) ) {
|
||||||
|
$wc_edm_threw = '';
|
||||||
|
ob_start();
|
||||||
|
try {
|
||||||
|
wpmgr_menu_glyph_style();
|
||||||
|
} catch ( \Throwable $e ) {
|
||||||
|
$wc_edm_threw = get_class( $e ) . ': ' . $e->getMessage();
|
||||||
|
}
|
||||||
|
$wc_edm_style = ob_get_clean();
|
||||||
|
|
||||||
|
wc_edm_ok(
|
||||||
|
'emitting the menu glyph style throws nothing',
|
||||||
|
'' === $wc_edm_threw,
|
||||||
|
$wc_edm_threw
|
||||||
|
);
|
||||||
|
wc_edm_ok(
|
||||||
|
'and what it emits is a style element carrying the glyph',
|
||||||
|
false !== strpos( $wc_edm_style, '<style>' )
|
||||||
|
&& false !== strpos( $wc_edm_style, '</style>' )
|
||||||
|
&& false !== strpos( $wc_edm_style, '\\221E' ),
|
||||||
|
'emitted: ' . substr( $wc_edm_style, 0, 120 )
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
echo "::warning::wpmgr_menu_glyph_style() is not defined, so the glyph style was not exercised.\n";
|
||||||
|
}
|
||||||
|
|
||||||
// The frozen hash of includes/shared-menu.php is asserted in ci/static.sh
|
// The frozen hash of includes/shared-menu.php is asserted in ci/static.sh
|
||||||
// against WPMGR_MENU_SHA in ci/plugin.conf, and deliberately NOT repeated
|
// against WPMGR_MENU_SHA in ci/plugin.conf, and deliberately NOT repeated
|
||||||
// here: two copies of the same constant drift, and the one that drifts is the
|
// here: two copies of the same constant drift, and the one that drifts is the
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* Plugin URI: https://gitea.nolimit.dk/kw/woo-discount-manager
|
* Plugin URI: https://gitea.nolimit.dk/kw/woo-discount-manager
|
||||||
* Update URI: https://gitea.nolimit.dk/kw/nolimit-discounts-dist
|
* Update URI: https://gitea.nolimit.dk/kw/nolimit-discounts-dist
|
||||||
* Description: Apply discounts and show/hide shipping methods based on the customer's email address (full address, domain or partial match).
|
* Description: Apply discounts and show/hide shipping methods based on the customer's email address (full address, domain or partial match).
|
||||||
* Version: 1.5.2
|
* Version: 1.5.3
|
||||||
* Author: Kristian Wind
|
* Author: Kristian Wind
|
||||||
* Author URI: https://gitea.nolimit.dk/kw
|
* Author URI: https://gitea.nolimit.dk/kw
|
||||||
* License: GPL-2.0-or-later
|
* License: GPL-2.0-or-later
|
||||||
@@ -28,7 +28,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
define( 'WC_EDM_VERSION', '1.5.2' );
|
define( 'WC_EDM_VERSION', '1.5.3' );
|
||||||
define( 'WC_EDM_PLUGIN_FILE', __FILE__ );
|
define( 'WC_EDM_PLUGIN_FILE', __FILE__ );
|
||||||
define( 'WC_EDM_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
define( 'WC_EDM_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
||||||
define( 'WC_EDM_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
define( 'WC_EDM_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
||||||
|
|||||||
Reference in New Issue
Block a user