Fix: trim whitespace from slot ID exclusions to prevent space-padded …#205
Conversation
…entries from failing to match
trrill
left a comment
There was a problem hiding this comment.
Added missing space before closing parentheses to appease the linting gods.
…es when we render in the input, supporting any legacy options that have extra spaces and new options that won't
There was a problem hiding this comment.
Thanks for the PR @trrill, works as expected. In thinking about it a bit more though, seems ideal that we shouldn't be storing data with extra spaces in the first place. I've pushed a commit that trims that extra space prior to save and then when rendering in the settings input, trim extra spaces (for backwards-compat with previously saved values) and add an extra space back with the comma: c5b4ed6
Your change is still needed to support anyone with previously saved data but then going forward, data will no longer have that extra space.
Let me know if that all makes sense to you though.
Yes, quite right about all of that! Thanks :) |
…entries from failing to match
Description of the Change
When a comma-separated list of slot IDs is entered in the plugin settings with spaces after commas (e.g.
ad--youtube1x1, ad-youtube1x1), the whitespace is preserved when building the$slot_ids_to_exclude_assocarray. This causes the serialized JavaScript object to contain space-padded keys (e.g." ad-youtube1x1") that will never match a real slot element ID, silently breaking the exclusion for those slots.The fix adds
trim()to each slot ID as it's added to the associative array, consistent with howsizes_to_excludealready handles whitespace viaarray_map/trim().How to test the Change
div-gpt-ad-123, div-gpt-ad-456AdRefreshControlJS objectslotIdsToExcludeare trimmed and match the actual slot element IDs on the pageChangelog Entry
Fixed - Trim whitespace from slot ID exclusion list entries to prevent space-padded keys from failing to match slot element IDs
Credits
Props @trrill
Checklist: