WC_Install::create_options
Default options.
Sets up the default options used on the settings page.
Method of the class: WC_Install{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = WC_Install::create_options();
WC_Install::create_options() WC Install::create options code WC 10.3.3
private static function create_options() {
// Include settings so that we can run through defaults.
include_once __DIR__ . '/admin/class-wc-admin-settings.php';
$settings = WC_Admin_Settings::get_settings_pages();
foreach ( $settings as $section ) {
if ( ! is_a( $section, 'WC_Settings_Page' ) || ! method_exists( $section, 'get_settings' ) ) {
continue;
}
$subsections = array_unique( array_merge( array( '' ), array_keys( $section->get_sections() ) ) );
/**
* We are using 'WC_Settings_Page::get_settings' on purpose even thought it's deprecated.
* See the method documentation for an explanation.
*/
foreach ( $subsections as $subsection ) {
foreach ( $section->get_settings( $subsection ) 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' ) );
}
}
}
}
// Define other defaults if not in setting screens.
add_option( 'woocommerce_single_image_width', '600', '', 'yes' );
add_option( 'woocommerce_thumbnail_image_width', '300', '', 'yes' );
add_option( 'woocommerce_checkout_highlight_required_fields', 'yes', '', 'yes' );
add_option( 'woocommerce_demo_store', 'no', '', 'no' );
if ( self::is_new_install() ) {
// Define initial tax classes.
WC_Tax::create_tax_class( __( 'Reduced rate', 'woocommerce' ) );
WC_Tax::create_tax_class( __( 'Zero rate', 'woocommerce' ) );
// For new installs, setup and enable Approved Product Download Directories.
wc_get_container()->get( Download_Directories_Sync::class )->init_feature( false, true );
}
}