Issue
The sanitize_title filter (priority 9) in WPSlug (Wen Pai Su Ge) intercepts WordPress core’s internal sanitize_title() call inside add_menu_page(). WordPress uses this call to generate the admin page hook suffix ($admin_page_hooks[$menu_slug]).
When All-in-One WP Migration (AIOWPM) registers its menu via add_menu_page('All-in-One WP Migration', ...), the following occurs:
- Without WPSlug: hook suffix =
all-in-one-wp-migration
(correct) - With WPSlug: the optimizer removes stop words such as
"in"→ hook suffix =all-one-wp-migration
(incorrect)
AIOWPM’s enqueue_import_scripts_and_styles($hook) performs a strict stripos match against the string all-in-one-wp-migration_page_ai1wm_import. The altered hook fails this match → CSS/JS assets are not enqueued → the import page loses all styling.
Scope of impact: Not limited to AIOWPM — any plugin whose menu title contains stop words (in, on, at, to, for, of, with, by, a, an, the) is affected.
Root Cause Analysis
WordPress uses sanitize_title() for two distinct purposes:
- Content slug generation: Used when saving posts, terms, or media — requires pinyin conversion and stop-word optimization.
- Internal identifier generation: Called by
add_menu_page()during theadmin_menuaction to generate the hook suffix for page identification.
WPSlug does not distinguish between these two contexts, causing internal identifiers to be incorrectly optimized.
Fix Proposal
Add a guard condition in processSanitizeTitle() using doing_action() to skip processing during admin menu registration:
// Skip during admin menu registration — sanitize_title() is used to
// generate hook suffixes, not content slugs.
if (doing_action('admin_menu') || doing_action('network_admin_menu') || doing_action('user_admin_menu')) {
return $title;
}
Why This Is Safe
add_menu_page()callssanitize_title()during theadmin_menuaction solely to generate hook suffixes — these are not content slugs and must remain unaltered.- Actual post/term slug saving never occurs during the
admin_menuaction — thus zero false positives. - Coverage extends to
network_admin_menuanduser_admin_menu, ensuring safety in Multisite environments.
Verification Results
Tested on the wapuu.com staging site with both WPSlug and AIOWPM enabled:
- During
admin_menu:sanitize_title("All-in-One WP Migration")→all-in-one-wp-migration
("in"preserved) - Hook fully matches
all-in-one-wp-migration_page_ai1wm_import
- Regression test: Chinese slug conversion remains unaffected
