Using WordPress functions inside classes without constructs?
-
Before I begin to ask, please see my file structure
/functions.php
/lib
/lib/settings.php/functions.php has just a little bit of code, aside from my copyright statments:
require_once(TEMPLATEPATH.'/../landBaronSl/lib/admin.php'); require_once(TEMPLATEPATH.'/../landBaronSl/lib/postMeta.php'); require_once(TEMPLATEPATH.'/../landBaronSl/lib/settings.php'); require_once(TEMPLATEPATH.'/../landBaronSl/lib/invoke.php'); new lbInvoke; // Setup the settings and registration variables $lbSettings = new lbSettings; register_activation_hook(__FILE__,$lbSettings->registerSettings());
The last line is causing an issue, I get “Fatal error: Call to undefined function register_setting()” and it’s referencing the settings file, line 37. The settings file looks like so:
class lbSettings{ function lbSettings(){ $this->__construct(); } function __construct(){ } public function registerSettings(){ $settingsArray = array( // General Settings 'lbTemplate', // The selected template // PostMeta Settings 'lbLandTypes', // Land types, will be an array() 'lbLandStyle', // Grass, snow, etc... an array of course 'lbLandManagers', // Users that will be able to have management options for the box in SL. ); foreach($settingsArray as $setting){ register_setting('lbSettingsGroup', $setting); } } }
During the last foreach loop is what it’s saying is a fatal error!
So before you say, “use the action hook in your construct” please know that’s not the solution I’m looking for. So my question is, how come WordPress functions cannot be utilized inside a class when it’s called the way I did? I’m lost and would appreciate an explanation of my failure if possible.
- The topic ‘Using WordPress functions inside classes without constructs?’ is closed to new replies.