code-snippets icon indicating copy to clipboard operation
code-snippets copied to clipboard

The plugin doesn't check if a function can be overridden or not and throw an error

Open kalonya opened this issue 3 years ago • 4 comments

If there is already a function wrapped by if(!function_exists('function_name')) {}, you can't override it via the plugin because it throws the error below.

CleanShot 2022-02-21 at 14 57 46@2x

But you can safely override that function with the same code used in the plugin with the functions.php file of the child theme without an error. Those kinds of functions should be overridden safely.

kalonya avatar Feb 21 '22 12:02 kalonya

I honestly think that the core use case of this plugin is not to override existing functions, but to add extra PHP handlers and IIFE JavaScript function calls. 😎

mxdpeep avatar May 07 '22 09:05 mxdpeep

While @mxdpeep is correct that this seems to be the more common usage, it would definitely be good to have support for pluggable functions. Currently the duplicate checker checks any functions defined in the snippet against those that already exist. I'm trying to think of a way to detect whether those are pluggable or not. Maybe we could add a manual override to disable the duplicate checker for specific functions/snippets?

sheabunge avatar Jul 05 '22 09:07 sheabunge

manual override switch looks like a promising solution

On Tue, Jul 5, 2022 at 11:29 AM Shea Bunge @.***> wrote:

While @mxdpeep https://github.com/mxdpeep is correct that this seems to be the more common usage, it would definitely be good to have support for pluggable functions. Currently the duplicate checker checks any functions defined in the snippet against those that already exist. I'm trying to think of a way to detect whether those are pluggable or not. Maybe we could add a manual override to disable the duplicate checker for specific functions/snippets?

— Reply to this email directly, view it on GitHub https://github.com/sheabunge/code-snippets/issues/123#issuecomment-1174837545, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAASMXTNVBAH2KXY224AQQDVSP6AZANCNFSM5O6MMZPA . You are receiving this because you were mentioned.Message ID: @.***>

mxdpeep avatar Jul 06 '22 03:07 mxdpeep