Tsalagi Posted September 13, 2010 Share Posted September 13, 2010 I have some code that I think would be best off in a class or some other more efficient practice but I'm not versed in OOP so I'm looking for suggestions. The three lines of code here represent a whole block of code. In that block the functions can be repeated several times with the arguments always different. Any suggestions? I've commented to code to explain it's relation. register_setting( 'features', THEME.' Features', 'validate_features' ); //There may be many of these functions related to only one register_setting() function add_settings_section('main_section', 'Main Settings', 'section_cb', __FILE__); //There may be many of these related to only one add_settings_section() function. Note the final argument "main_section" drawing the relationship add_settings_field('banner_heading', 'Banner Heading:', 'banner_heading_setting', __FILE__, 'main_section'); add_settings_field('footer_text', 'Footer Text:', 'footer_text_setting', __FILE__, 'main_section'); Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/213327-convert-procedural-program-into-class/ Share on other sites More sharing options...
trq Posted September 14, 2010 Share Posted September 14, 2010 Simply converting functions into methods within a class doesn't make it OOP. If you have no need for the data persistence that objects contain, you likely have no need to make this code a class. Quote Link to comment https://forums.phpfreaks.com/topic/213327-convert-procedural-program-into-class/#findComment-1110786 Share on other sites More sharing options...
Tsalagi Posted September 14, 2010 Author Share Posted September 14, 2010 Thanks. I'm not sure about data persistence but since I'm learning, I'll look into it. Quote Link to comment https://forums.phpfreaks.com/topic/213327-convert-procedural-program-into-class/#findComment-1110803 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.