New Landing How can we help? Themeforest Theme Support Neighborhood can't override a few functions in sf-header (no function_exists call)

Viewing 15 posts - 1 through 15 (of 17 total)
  • #57841
    airuck
    Member
    Post count: 36

    A few functions in sf-header.php aren’t overrideable, specifically:

    1. sf_aux_links
    2. sf_woo_links
    3. sf_get_cart
    4. sf_get_wishlist

    Because these methods all contain html output, any tweaking to header widths (whether by child theme or just in functions.php) to the header display has to go through them. sf_top_bar, sf_header, sf_logo etc all contain the if (!function_exists()) check before declaration, allowing them to be overriden.
    Can these 4 functions also have if_exists checks? This way a function can be tweaked without overriding the whole file, and it’s 4 lines of additional code with no compatibility-breaking issues.

    Thanks!

    #57888
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Please create a file functions.php at neighborhood child theme and here you can override all functions with any check easily .

    Thanks ๐Ÿ™‚
    With Best Regards
    Swift Ideas

    #57906
    airuck
    Member
    Post count: 36

    Hi Mohammad,

    Well, I have a functions.php in child theme, as mentioned. You cannot override any functions except those that will conditionally check to see if they already exist. The ones I listed don’t do this. If I take your advice, I’ll get a fatal error due to redeclaring an existing function (because the swift framework will try to make the function again when that code runs, as the functions.php runs first).

    The addition of these function_exists checks in the swift framework sf-header.php would allow them to be overridden. Can you pass this along to one of the developers?

    Also, is there an easier method for developer-related requests, or swift-framework-specific tickets, or is this the best method?

    I appreciate the help!

    #57918
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    As you mentioned that need to put if (!function_exists()) check so you can put functions exist check at sf-header.php for sf_aux_links , sf_woo_links , sf_get_cart and sf_get_wishlist . So here how can i help you to put this check ? There is also a one method , just copy this file and paste at child theme so here you can modify easily any functions of sf-header.php .

    Thanks ๐Ÿ™‚
    With Best Regards
    Swift Ideas

    #57934
    airuck
    Member
    Post count: 36

    Hey Mohammad,

    You’re right, I can add those checks to sf-header.php. But if I do so, I’ve now overridden the whole sf-header file, and have to be careful when upgrading not to overwrite it. I want to change as little as possible any time I’m overriding swift framework / neighborhood functionality. If I just want to override one file for its html output, that’s very different from having to keep up to date on the whole sf-header file, does that make sense? It’s all about changing as few things as possible to your core framework and theme while still supporting our needs in the child theme.

    What I’m asking for is for you to add the function_exists check to the file in your code and release it with the next version of swift framework / neighborhood. This way I add these changes locally (to sf-header.php) and know my code won’t break when I update to your next version, because it will contain the function_exists check.

    Then other developers can use this in the future, and it has no negative implications on backwards compatibility or anything–the function_exists checks also already being done in the same file for other functions, so I’m hoping it can go in the next version.

    Thanks again for your time (:

    #57937
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Thank you for your suggestion . I will forward this to the developer .
    Thanks ๐Ÿ™‚
    With Best Regards
    Swift Ideas

    #58148
    Swift Ideas – Ed
    Keymaster
    Post count: 15264

    I will add these override options for the next update ๐Ÿ™‚

    Thanks,

    – Ed

    #58610
    airuck
    Member
    Post count: 36

    Awesome, you’re the best!

    #58613
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Thanks ๐Ÿ™‚
    With Best Regards
    Swift Ideas

    #60546
    airuck
    Member
    Post count: 36

    Ed, can you do the same for sf_mini_header and sf_mobile_search functions in the same file (sf-header.php line 424)?
    They also output html, but currently don’t have function_exists calls. Hugely appreciated!

    #60553
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Thank you for your suggestion .

    #60778
    Swift Ideas – Ed
    Keymaster
    Post count: 15264

    Added for the next update, thanks.

    – Ed

    #79157
    iquarius
    Member
    Post count: 32

    Hello there,

    I wonder if overrides mentioned here #58148 are already in place. I need to modify the output of sf_main_menu, sf_aux_links , sf_woo_links , sf_get_cart… etc (For Dante)

    #79179
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    You can modify these functions output through child theme so please copy all of these functions from sf-header.php and paste at functions.php in child theme. Here you can easily edit these functions.

    Thanks ๐Ÿ™‚
    With Best Regards
    Swift Ideas

    #79180
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,

    @iquarius
    – You can modify these functions output through child theme so please copy all of these functions from sf-header.php and paste at functions.php in child theme. Here you can easily edit these functions.

    Thanks ๐Ÿ™‚
    With Best Regards
    Swift Ideas

Viewing 15 posts - 1 through 15 (of 17 total)

You must be logged in to reply to this topic.