diff --git a/includes/admin/class-wc-call-for-price-settings-general.php b/includes/admin/class-wc-call-for-price-settings-general.php index b6a25b8..122e6f9 100644 --- a/includes/admin/class-wc-call-for-price-settings-general.php +++ b/includes/admin/class-wc-call-for-price-settings-general.php @@ -43,13 +43,20 @@ class Alg_WC_Call_For_Price_Settings_General { */ public function __construct() { - $this->id = ''; - $this->desc = __( 'General', 'woocommerce-call-for-price' ); + $this->id = ''; + add_action( 'init', array( &$this, 'add_cfp_desc_general' ) ); add_filter( 'woocommerce_get_sections_alg_call_for_price', array( $this, 'settings_section' ) ); add_filter( 'woocommerce_get_settings_alg_call_for_price_' . $this->id, array( $this, 'get_settings' ), PHP_INT_MAX ); } + /** + * Add desc to setting page. + */ + public function add_cfp_desc_general() { + $this->desc = __( 'General', 'woocommerce-call-for-price' ); + } + /** * Wettings_section. * diff --git a/includes/admin/class-wc-call-for-price-settings-product-types.php b/includes/admin/class-wc-call-for-price-settings-product-types.php index 408e204..a01c4a7 100644 --- a/includes/admin/class-wc-call-for-price-settings-product-types.php +++ b/includes/admin/class-wc-call-for-price-settings-product-types.php @@ -37,6 +37,14 @@ class Alg_WC_Call_For_Price_Settings_Product_Types { */ public function __construct() { add_filter( 'woocommerce_get_sections_alg_call_for_price', array( $this, 'settings_section' ) ); + add_action( 'init', array( &$this, 'add_cfp_desc_product_types' ) ); + add_action( 'woocommerce_admin_field_alg_wc_call_for_price_textarea', array( $this, 'output_custom_textarea' ) ); + add_filter( 'woocommerce_admin_settings_sanitize_option', array( $this, 'unclean_custom_textarea' ), PHP_INT_MAX, 3 ); + } + /** + * Add desc to setting page. + */ + public function add_cfp_desc_product_types() { $this->product_types = array( 'simple' => __( 'Simple Products', 'woocommerce-call-for-price' ), 'variable' => __( 'Variable Products', 'woocommerce-call-for-price' ), @@ -46,8 +54,6 @@ public function __construct() { foreach ( $this->product_types as $product_type_id => $product_type_desc ) { add_filter( 'woocommerce_get_settings_alg_call_for_price_' . $product_type_id, array( $this, 'get_settings' ), PHP_INT_MAX ); } - add_action( 'woocommerce_admin_field_alg_wc_call_for_price_textarea', array( $this, 'output_custom_textarea' ) ); - add_filter( 'woocommerce_admin_settings_sanitize_option', array( $this, 'unclean_custom_textarea' ), PHP_INT_MAX, 3 ); } /** diff --git a/woocommerce-call-for-price.php b/woocommerce-call-for-price.php index c027d5d..a07333b 100644 --- a/woocommerce-call-for-price.php +++ b/woocommerce-call-for-price.php @@ -103,7 +103,7 @@ public static function instance() { public function __construct() { // Set up localisation. - load_plugin_textdomain( 'woocommerce-call-for-price', false, dirname( plugin_basename( __FILE__ ) ) . '/langs/' ); + add_action( 'init', array( $this, 'cfp_load_text_domain' ) ); // Include required files. $this->includes(); @@ -116,6 +116,13 @@ public function __construct() { } } + /** + * Added plugin text domain. + */ + public function cfp_load_text_domain() { + load_plugin_textdomain( 'woocommerce-call-for-price', false, dirname( plugin_basename( __FILE__ ) ) . '/langs/' ); + } + /** * Show action links on the plugin screen *