I've got a parent class My_Admin
with a public property $options
I've got a child class My_Notices
that needs to access the $options
property.
If, in the child class, I throw parent::__construct()
into the child class's __construct()
, I am able to access $options
BUT it duplicates the entire output of the parent class. In other words, I'm getting two html page outputs on the same page, because of the instantiation of the child class calling parent::_construct()
.
I've tried declaring $options
in my child construct like public function __construct($options)
but then it tells me:
Warning: Missing argument 1 for My_Notices::__construct()
** EDIT **
Here's a breakdown of the classes:
class My_Admin
{
private $sections;
protected $settings;
protected $defaults;
public $options;
public function __construct()
{
$this->settings = array();
$this->get_settings();
$this->defaults = array( /* stuff here */ );
$this->sections = array( /* stuff here */ );
add_filter('plugin_action_links', array($this, 'pluginpage'), 10, 2);
add_action('admin_menu', array($this, 'menu'));
add_action('admin_enqueue_scripts', array($this, 'enqueue'));
add_action('admin_init', array($this, 'deregister'), 20);
add_action('wp_ajax_my_save', array($this, 'save'));
if(!get_option('my_options')) $this->initialize();
$this->options = get_option('my_options');
}
}
class My_Notices extends My_Admin
{
public function __construct()
{
add_action('admin_notices', array($this, 'baseconfig'));
add_action('admin_init', array($this, 'baseignore'));
}
public function baseconfig(){
global $pagenow;
$uid = get_current_user_id();
/* I NEED TO ACCESS $options HERE */
if(!$this->options['base1'] || !$this->options['bs1name'])
{
if(!get_user_meta($uid, 'my_notice'))
{
}
}
}
}