Originally Posted by
RobertH
Ah okay, that makes sense. That works fine!
What about overrides to files in /includes/functions/ or /includes/classes/? I found
this thread from 2009 where a user advises to create an override in /init_includes/, but is there a built-in method for doing this now? Or what would be the suggested procedure for overrides on those files that don't have custom_template override systems?
Using the /includes/auto_loaders/overrides and /includes/init_includes/overrides sub-directories work, but their use (IMO) can cause issues when you're upgrading. I used those methods in the past and then, when upgrading, forgot that they were there ... and wound up spending much more time trying to figure out what the heck was going on.
My advice, make your customized changes directly to the core files in /includes/functions and /includes/init_includes and heavily comment the changes. I've adopted the methods used by the legendary Conor Kerr (now deceased) as illustrated below.
Let's pretend that you want to modify the function zen_get_buy_now_button (present in /includes/functions_general.php) to add a specific class to the output when the associated product is "call_for_price".
The original code fragment in that function reads:
Code:
case ($button_check->fields['product_is_call'] == '1'):
$return_button = '<a href="' . zen_href_link(FILENAME_CONTACT_US, '', 'SSL') . '">' . TEXT_CALL_FOR_PRICE . '</a>';
break;
I'd make the update as follows:
Code:
case ($button_check->fields['product_is_call'] == '1'):
//-bof-20180227-lat9-Add class to enable link's styling
// $return_button = '<a href="' . zen_href_link(FILENAME_CONTACT_US, '', 'SSL') . '">' . TEXT_CALL_FOR_PRICE . '</a>';
$return_button = '<a href="' . zen_href_link(FILENAME_CONTACT_US, '', 'SSL') . '" class="buynow-call-for-price">' . TEXT_CALL_FOR_PRICE . '</a>';
//-eof-20180227-lat9
break;
The change is surrounded by //-bof and //-eof comments, with a blank line before the //-bof and after the //-eof (it "helps" your file-comparison program properly locate the changes). Keeping the original code also helps on an upgrade, so you can see what was changed!
Bookmarks