File "comp.germanized.php"
Full Path: /home/siazco/grocery.siazco.se/wp-content/plugins/woocommerce-table-rate-shipping/compatibility/comp.germanized.php
File size: 3.06 KB
MIME-type: text/x-php
Charset: utf-8
<?php
/*
* Table Rate Shipping Method Extender Class
*/
if ( ! defined( 'ABSPATH' ) )
exit;
// Check if WooCommerce is active
if ( class_exists( 'WooCommerce' ) && class_exists('WooCommerce_Germanized') ) {
if ( class_exists( 'BETRS_Germanized' ) ) return;
class BETRS_Germanized {
/**
* Cloning is forbidden. Will deactivate prior 'instances' users are running
*
* @since 4.4
*/
public function __clone() {
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cloning this class could cause catastrophic disasters!', 'be-table-ship' ), '4.0' );
}
/**
* Unserializing instances of this class is forbidden.
*
* @since 4.4
*/
public function __wakeup() {
_doing_it_wrong( __FUNCTION__, esc_html__( 'Unserializing is forbidden!', 'be-table-ship' ), '4.0' );
}
/*
* Table Rates from Database
*/
private $shipping_fields = array();
/**
* __construct function.
*
* @access public
* @return void
*/
function __construct() {
// modify the necessary settings values through hooks and filters
add_filter( 'woocommerce_gzd_shipping_provider_method_admin_settings', array( $this, 'get_germanized_field_exceptions' ), 9999, 1 );
add_filter( 'betrs_shipping_settings_fields_exceptions', array( $this, 'add_germanized_field_exceptions' ), 23, 2 );
add_filter( 'betrs_shipping_settings_fields_sections', array( $this, 'add_germanized_section' ), 23, 1 );
}
/**
* get Germanized settings fields for shipping methods.
*
* @access public
* @param array $sections
* @return array
*/
function get_germanized_field_exceptions( $method_settings ) {
// save germanized settings fields locally
$this->shipping_fields += $method_settings;
return $method_settings;
}
/**
* remove all Germanized settings fields from the 'Other Plugins' section on the settings page.
*
* @access public
* @param array $sections
* @return array
*/
function add_germanized_field_exceptions( $exceptions, $instance_fields ) {
if( is_array( $this->shipping_fields ) && ! empty( $this->shipping_fields ) ) {
$exceptions += $this->shipping_fields;
}
// add field that is not added through the filter
$exceptions['label_configuration_set_shipping_provider_stop_title'] = $instance_fields['label_configuration_set_shipping_provider_stop_title'];
$this->shipping_fields['label_configuration_set_shipping_provider_stop_title'] = $instance_fields['label_configuration_set_shipping_provider_stop_title'];
return $exceptions;
}
/**
* add new section box to settings page.
*
* @access public
* @param array $sections
* @return array
*/
function add_germanized_section( $sections ) {
if( is_array( $sections ) && ! isset( $sections['germanized'] ) ) {
$sections['germanized'] = array(
'title' => esc_html__( 'Germanized', 'be-table-ship' ),
'settings' => $this->shipping_fields,
);
}
return $sections;
}
}
new BETRS_Germanized();
}
?>