OneSignal / OneSignal-WordPress-Plugin

OneSignal is a free push notification service for web and mobile apps. This plugin makes it easy to integrate your website with OneSignal Push Notifications. https://onesignal.com
Other
80 stars 42 forks source link

fixed apostrophe issue and small ui update to custom push metabox #262

Closed jfishman1 closed 3 years ago

jfishman1 commented 3 years ago

The Problem:

The customer adds apostrophe to any field in the OneSignal settings:

screen_shot_2021-01-14_at_2 32 33_pm

Upon save, a slash gets added before the apostrophes. This happens on every save which leads to a buildup of slashes.

Screen Shot 2021-01-14 at 2 33 09 PM

These slashes show up on the prompt and the apostrophe gets translated to HTML version:

Screen Shot 2021-01-14 at 2 33 35 PM

Solution

The following two methods are needed together in order for the fix to work:

stripslashes_deep was added to remove slashes automatically added upon saving with an apostrophe. It does not remove slashes added purposely e.g: in UTM params. a side-effect of this workaround is that the apostrophe is converted to HTML version: &#039 which is why the next function is also needed.

decode_entities was added because without it, apostrophes would show up as the HTML version: '. This function was previously used elsewhere in the plugin.

This change is Reviewable