fix: Remove redundant location parameter check in SVG icon shortcode#131
Open
kausaralm wants to merge 1 commit intooceanwp:masterfrom
Open
fix: Remove redundant location parameter check in SVG icon shortcode#131kausaralm wants to merge 1 commit intooceanwp:masterfrom
kausaralm wants to merge 1 commit intooceanwp:masterfrom
Conversation
Fixes oceanwp#116 - The filter_var() already converts the location attribute to a boolean, making the subsequent if/else block unnecessary. This simplification removes 5 redundant lines and directly assigns the already-converted boolean value.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes #116 by removing redundant conditional logic in the SVG icon shortcode that was causing the
locationparameter to behave unexpectedly.Problem
In Ocean Extra v2.4.7, the
locationattribute handling was refactored to usefilter_var()for boolean conversion. However, the code retained an unnecessary if/else block that was checking string values instead of booleans:The conditional block served no purpose since
filter_var()already returns a boolean value.Solution
Remove the redundant conditional block and directly assign the converted value:
Code Changes
Before (11 lines)
After (7 lines)
Why This Helps Users
Non-technical users rely on shortcodes working as documented. When the
locationparameter is ignored or always returnstrue, users cannot control whether the shortcode usesocean_svg()oroceanwp_icon()functions. This fix restores the expected behavior:[oceanwp_icon icon="example" location="true"]- Usesocean_svg()[oceanwp_icon icon="example" location="false"]- Usesoceanwp_icon()Testing
[oceanwp_icon icon="icon-class" location="true"]- Verify it callsocean_svg()[oceanwp_icon icon="icon-class" location="false"]- Verify it callsoceanwp_icon()[oceanwp_icon icon="icon-class"]without location - Verify it defaults toocean_svg()(location=true)Checklist