/** * Default options * * Sets up the default options used on the settings page * * @access public */ function create_options() { /** * This loads the settings for the plugin. * First checks what version of WooCommerce is active, * then loads the appropriate format. */ if (version_compare(MAILPOET_WOOVERSION, "2.0.20", '<=')) { include_once 'settings/v2.0.20/class-mailpoet-woocommerce-admin-settings.php'; $this->settings = new MailPoet_WooCommerce_Add_on_Admin_Settings(); $this->settings->get_settings(); // Run through each settings to load the default settings. foreach ($this->settings as $value) { if (isset($value['default']) && isset($value['id'])) { $autoload = isset($value['autoload']) ? (bool) $value['autoload'] : true; add_option($value['id'], $value['default'], '', $autoload ? 'yes' : 'no'); } } } else { // Include settings so that we can run through defaults. include_once 'class-mailpoet-woocommerce-admin-settings.php'; $settings = MailPoet_WooCommerce_Admin_Settings::get_settings_pages(); // Run through each section and settings to load the default settings. foreach ($settings as $section) { $section = $section->get_settings(); foreach ($section as $value) { if (isset($value['default']) && isset($value['id'])) { $autoload = isset($value['autoload']) ? (bool) $value['autoload'] : true; add_option($value['id'], $value['default'], '', $autoload ? 'yes' : 'no'); } } } } }
/** * Get a setting from the settings API. * * @param mixed $option * @return string */ function mailpoet_woocommerce_settings_get_option($option_name, $default = '') { if (!class_exists('MailPoet_WooCommerce_Admin_Settings')) { include 'class-mailpoet-woocommerce-admin-settings.php'; } return MailPoet_WooCommerce_Admin_Settings::get_option($option_name, $default); }