Automattic\WooCommerce\Internal\Admin\Logging
Settings::get_default_handler_setting_definition
The definition for the default_handler setting.
Method of the class: Settings{}
Hooks from the method
Returns
Array.
Usage
// private - for code of main (parent) class only $result = $this->get_default_handler_setting_definition(): array;
Settings::get_default_handler_setting_definition() Settings::get default handler setting definition code WC 10.3.5
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,
);
}