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.
|
|
|
|
* @since 2.7.0
|
|
|
|
*/
|
|
|
|
public static function register() {
|
2016-03-23 19:36:59 +00:00
|
|
|
add_filter( 'woocommerce_settings_groups', array( 'WC_Helper_Settings', 'register_groups' ) );
|
|
|
|
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-03-07 21:46:40 +00:00
|
|
|
* @since 2.7.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',
|
|
|
|
'type' => 'page',
|
|
|
|
'bad' => 'value',
|
|
|
|
'label' => __( 'Test Extension', 'woocommerce' ),
|
|
|
|
'description' => __( 'My awesome test settings.', 'woocommerce' ),
|
|
|
|
);
|
2016-03-23 19:36:59 +00:00
|
|
|
$groups[] = array(
|
2016-03-21 21:45:08 +00:00
|
|
|
'id' => 'test-2',
|
|
|
|
'type' => 'page',
|
|
|
|
'label' => __( 'Test Extension', 'woocommerce' ),
|
|
|
|
'description' => '',
|
|
|
|
);
|
2016-03-23 19:36:59 +00:00
|
|
|
$groups[] = array(
|
2016-03-07 21:46:40 +00:00
|
|
|
'id' => 'coupon-data',
|
|
|
|
'type' => 'metabox',
|
|
|
|
'label' => __( 'Coupon Data', 'woocommerce' ),
|
|
|
|
);
|
2016-03-23 19:36:59 +00:00
|
|
|
$groups[] = array(
|
2016-03-07 21:46:40 +00:00
|
|
|
'id' => 'invalid',
|
|
|
|
);
|
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-03-21 21:45:08 +00:00
|
|
|
* @since 2.7.0
|
2016-03-23 19:36:59 +00:00
|
|
|
* @param array $settings
|
2016-03-21 21:45:08 +00:00
|
|
|
* @return array
|
|
|
|
*/
|
2016-03-23 19:36:59 +00:00
|
|
|
public static function register_settings( $settings ) {
|
|
|
|
$settings[] = array(
|
|
|
|
'id' => 'catalog_options',
|
|
|
|
'label' => __( 'Shop & Product Pages', 'woocommerce' ),
|
|
|
|
'type' => 'title',
|
2016-03-21 21:45:08 +00:00
|
|
|
);
|
2016-03-23 19:36:59 +00:00
|
|
|
$settings[] = array(
|
|
|
|
'id' => 'woocommerce_shop_page_display',
|
|
|
|
'label' => __( 'Shop Page Display', 'woocommerce' ),
|
|
|
|
'description' => __( 'This controls what is shown on the product archive.', 'woocommerce' ),
|
|
|
|
'default' => '',
|
|
|
|
'type' => 'select',
|
|
|
|
'options' => array(
|
|
|
|
'' => __( 'Show products', 'woocommerce' ),
|
|
|
|
'subcategories' => __( 'Show categories & subcategories', 'woocommerce' ),
|
|
|
|
'both' => __( 'Show both', 'woocommerce' ),
|
|
|
|
),
|
2016-03-21 21:45:08 +00:00
|
|
|
);
|
2016-03-23 19:36:59 +00:00
|
|
|
$settings[] = array(
|
|
|
|
'id' => 'woocommerce_enable_lightbox',
|
|
|
|
'label' => __( 'Product Image Gallery', 'woocommerce' ),
|
|
|
|
'description' => __( 'Enable Lightbox for product images', 'woocommerce' ),
|
|
|
|
'default' => 'yes',
|
|
|
|
'tip' => __( 'Product gallery images will open in a lightbox.', 'woocommerce' ),
|
|
|
|
'type' => 'checkbox',
|
|
|
|
);
|
|
|
|
return $settings;
|
2016-03-21 21:45:08 +00:00
|
|
|
}
|
|
|
|
|
2016-03-07 21:46:40 +00:00
|
|
|
}
|