, 'options' => $all_statuses, ); $settings[] = array( 'id' => 'woocommerce_default_date_range', 'option_key' => 'woocommerce_default_date_range', 'label' => __( 'Default Date Range', 'woocommerce' ), 'description' => __( 'Default Date Range', 'woocommerce' ), 'default' => 'period=month&compare=previous_year', 'type' => 'text', ); $settings[] = array( 'id' => 'woocommerce_date_type', 'option_key' => 'woocommerce_date_type', 'label' => __( 'Date Type', 'woocommerce' ), 'description' => __( 'Database date field considered for Revenue and Orders reports', 'woocommerce' ), 'type' => 'select', 'options' => array( 'date_created' => 'date_created', 'date_paid' => 'date_paid', 'date_completed' => 'date_completed', ), ); if ( Features::is_enabled( 'analytics-scheduled-import' ) ) { $settings[] = array( 'id' => 'woocommerce_analytics_scheduled_import', 'option_key' => 'woocommerce_analytics_scheduled_import', 'label' => __( 'Updates', 'woocommerce' ), 'description' => __( 'Controls how analytics data is imported from orders.', 'woocommerce' ), 'type' => 'radio', 'default' => null, // Default to null so we can know if it's a new site or an existing site. New sites will have the option set. 'options' => array( 'yes' => __( 'Scheduled (recommended)', 'woocommerce' ), 'no' => __( 'Immediately', 'woocommerce' ), ), ); // Add hidden setting for the import interval to display in the client side. $import_interval = \Automattic\WooCommerce\Internal\Admin\Schedulers\OrdersScheduler::get_import_interval(); $import_interval = absint( $import_interval ); // Format the import interval to a human-readable string. $import_interval_string = human_time_diff( 0, $import_interval ); $settings[] = array( 'id' => 'woocommerce_analytics_import_interval', 'option_key' => 'woocommerce_analytics_import_interval', 'type' => 'hidden', 'default' => $import_interval_string, ); } return $settings; } /** * Gets custom settings used for WC Admin. * * @param array $settings Array of settings to merge into. * @return array */ private function get_custom_settings( $settings ) { $wc_rest_settings_options_controller = new \WC_REST_Setting_Options_Controller(); $wc_admin_group_settings = $wc_rest_settings_options_controller->get_group_settings( 'wc_admin' ); $settings['wcAdminSettings'] = array(); foreach ( $wc_admin_group_settings as $setting ) { if ( ! empty( $setting['id'] ) ) { $settings['wcAdminSettings'][ $setting['id'] ] = $setting['value']; } } return $settings; } /** * Add the settings UI schema for the current classic settings page. * * @param array $settings Array of component settings. * @return array */ private function add_settings_ui_schema( array $settings ): array { try { if ( ! class_exists( SettingsUIRequestContext::class ) ) { return $settings; } $context = SettingsUIRequestContext::get_current(); } catch ( \Throwable $e ) { return $settings; } if ( ! $context ) { return $settings; } $schema = $context->get_schema(); if ( ! is_array( $schema ) ) { return $settings; } $page_id = $context->get_page_id(); $section_key = $context->get_current_section_key(); if ( ! isset( $settings['settingsUI'] ) || ! is_array( $settings['settingsUI'] ) ) { $settings['settingsUI'] = array(); } if ( ! isset( $settings['settingsUI'][ $page_id ] ) || ! is_array( $settings['settingsUI'][ $page_id ] ) ) { $settings['settingsUI'][ $page_id ] = array(); } $settings['settingsUI'][ $page_id ][ $section_key ] = $schema; return $settings; } }