2016-03-07 21:46:40 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class WC_Helper_Settings.
|
|
|
|
*
|
|
|
|
* This helper class should ONLY be used for unit tests!
|
|
|
|
*/
|
|
|
|
class WC_Helper_Settings {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hooks in some dummy data for testing the settings REST API.
|
2016-07-19 18:24:05 +00:00
|
|
|
*
|
2017-03-15 16:36:53 +00:00
|
|
|
* @since 3.0.0
|
2016-03-07 21:46:40 +00:00
|
|
|
*/
|
|
|
|
public static function register() {
|
2016-03-23 19:36:59 +00:00
|
|
|
add_filter( 'woocommerce_settings_groups', array( 'WC_Helper_Settings', 'register_groups' ) );
|
2016-03-28 19:04:26 +00:00
|
|
|
add_filter( 'woocommerce_settings-test', array( 'WC_Helper_Settings', 'register_test_settings' ) );
|
2016-03-07 21:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-03-23 19:36:59 +00:00
|
|
|
* Registers some example setting groups, including invalid ones that should not show up in JSON responses.
|
2016-07-19 18:24:05 +00:00
|
|
|
*
|
2017-03-15 16:46:02 +00:00
|
|
|
* @since 3.0.0
|
2016-03-23 19:36:59 +00:00
|
|
|
* @param array $groups
|
2016-03-07 21:46:40 +00:00
|
|
|
* @return array
|
|
|
|
*/
|
2016-03-23 19:36:59 +00:00
|
|
|
public static function register_groups( $groups ) {
|
|
|
|
$groups[] = array(
|
2016-03-07 21:46:40 +00:00
|
|
|
'id' => 'test',
|
|
|
|
'bad' => 'value',
|
2016-10-12 10:16:30 +00:00
|
|
|
'label' => 'Test extension',
|
|
|
|
'description' => 'My awesome test settings.',
|
2016-09-07 22:05:45 +00:00
|
|
|
'option_key' => '',
|
2016-03-07 21:46:40 +00:00
|
|
|
);
|
2016-03-23 19:36:59 +00:00
|
|
|
$groups[] = array(
|
2016-03-24 21:01:22 +00:00
|
|
|
'id' => 'sub-test',
|
|
|
|
'parent_id' => 'test',
|
2016-10-12 10:16:30 +00:00
|
|
|
'label' => 'Sub test',
|
2016-03-21 21:45:08 +00:00
|
|
|
'description' => '',
|
2016-09-07 22:05:45 +00:00
|
|
|
'option_key' => '',
|
2016-03-21 21:45:08 +00:00
|
|
|
);
|
2016-03-23 19:36:59 +00:00
|
|
|
$groups[] = array(
|
2019-05-01 22:05:00 +00:00
|
|
|
'id' => 'coupon-data',
|
|
|
|
'label' => 'Coupon data',
|
|
|
|
'option_key' => '',
|
2016-03-07 21:46:40 +00:00
|
|
|
);
|
2016-03-23 19:36:59 +00:00
|
|
|
$groups[] = array(
|
2019-05-01 22:05:00 +00:00
|
|
|
'id' => 'invalid',
|
|
|
|
'option_key' => '',
|
2016-03-07 21:46:40 +00:00
|
|
|
);
|
2016-03-23 19:36:59 +00:00
|
|
|
return $groups;
|
2016-03-07 21:46:40 +00:00
|
|
|
}
|
|
|
|
|
2016-03-21 21:45:08 +00:00
|
|
|
/**
|
2016-03-23 19:36:59 +00:00
|
|
|
* Registers some example settings.
|
2016-07-19 18:24:05 +00:00
|
|
|
*
|
2017-03-15 16:46:02 +00:00
|
|
|
* @since 3.0.0
|
2016-03-23 19:36:59 +00:00
|
|
|
* @param array $settings
|
2016-03-21 21:45:08 +00:00
|
|
|
* @return array
|
|
|
|
*/
|
2016-03-24 21:01:22 +00:00
|
|
|
public static function register_test_settings( $settings ) {
|
2016-03-23 19:36:59 +00:00
|
|
|
$settings[] = array(
|
|
|
|
'id' => 'woocommerce_shop_page_display',
|
2016-10-12 10:16:30 +00:00
|
|
|
'label' => 'Shop page display',
|
|
|
|
'description' => 'This controls what is shown on the product archive.',
|
2016-03-23 19:36:59 +00:00
|
|
|
'default' => '',
|
|
|
|
'type' => 'select',
|
|
|
|
'options' => array(
|
2016-10-12 10:16:30 +00:00
|
|
|
'' => 'Show products',
|
|
|
|
'subcategories' => 'Show categories & subcategories',
|
|
|
|
'both' => 'Show both',
|
2016-03-23 19:36:59 +00:00
|
|
|
),
|
2016-09-07 22:05:45 +00:00
|
|
|
'option_key' => 'woocommerce_shop_page_display',
|
2016-03-21 21:45:08 +00:00
|
|
|
);
|
2016-03-23 19:36:59 +00:00
|
|
|
return $settings;
|
2016-03-21 21:45:08 +00:00
|
|
|
}
|
2016-03-07 21:46:40 +00:00
|
|
|
}
|