Automattic\WooCommerce\Internal\Admin\Logging

Settings::get_default_handler_setting_definition()privateWC 1.0

The definition for the default_handler setting.

Метод класса: Settings{}

Хуки из метода

Возвращает

Массив.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->get_default_handler_setting_definition(): array;

Код Settings::get_default_handler_setting_definition() WC 9.7.1

private function get_default_handler_setting_definition(): array {
	$handler_options = array(
		LogHandlerFileV2::class  => __( 'File system (default)', 'woocommerce' ),
		WC_Log_Handler_DB::class => __( 'Database (not recommended on live sites)', 'woocommerce' ),
	);

	/**
	 * Filter the list of logging handlers that can be set as the default handler.
	 *
	 * @param array $handler_options An associative array of class_name => description.
	 *
	 * @since 8.6.0
	 */
	$handler_options = apply_filters( 'woocommerce_logger_handler_options', $handler_options );

	$current_value = $this->get_default_handler();
	if ( ! array_key_exists( $current_value, $handler_options ) ) {
		$handler_options[ $current_value ] = $current_value;
	}

	$desc = array();

	$desc[] = __( 'Note that if this setting is changed, any log entries that have already been recorded will remain stored in their current location, but will not migrate.', 'woocommerce' );

	$hardcoded = ! is_null( Constants::get_constant( 'WC_LOG_HANDLER' ) );
	if ( $hardcoded ) {
		$desc[] = sprintf(
			// translators: %s is the name of a code variable.
			__( 'This setting cannot be changed here because it is defined in the %s constant.', 'woocommerce' ),
			'<code>WC_LOG_HANDLER</code>'
		);
	}

	return array(
		'title'       => __( 'Log storage', 'woocommerce' ),
		'desc_tip'    => __( 'This determines where log entries are saved.', 'woocommerce' ),
		'id'          => self::PREFIX . 'default_handler',
		'type'        => 'radio',
		'value'       => $current_value,
		'default'     => self::DEFAULTS['default_handler'],
		'autoload'    => false,
		'options'     => $handler_options,
		'disabled'    => $hardcoded ? array_keys( $handler_options ) : array(),
		'desc'        => implode( '<br><br>', $desc ),
		'desc_at_end' => true,
	);
}