activation-tracker.php
1 week ago
display-options.php
1 week ago
field-type-settings.php
1 week ago
field.php
1 week ago
filed-validation.php
1 week ago
myaccount-edit-address.php
1 week ago
myaccount-field-processor.php
1 week ago
plugin.php
1 week ago
settings.php
1 week ago
tracker.php
1 week ago
user-meta-checkout.php
1 week ago
user-meta.php
1 week ago
user-profile.php
1 week ago
settings.php
87 lines
| 1 | <?php |
| 2 | |
| 3 | use WPDesk\FCF\Free\Settings\Form\EditFieldsForm; |
| 4 | if ( ! defined( 'ABSPATH' ) ) { |
| 5 | exit; // Exit if accessed directly |
| 6 | } |
| 7 | |
| 8 | class Flexible_Checkout_Fields_Settings { |
| 9 | |
| 10 | /** |
| 11 | * @var Flexible_Checkout_Fields_Plugin |
| 12 | */ |
| 13 | public $plugin; |
| 14 | |
| 15 | /** |
| 16 | * Flexible_Checkout_Fields_Settings constructor. |
| 17 | * |
| 18 | * @param Flexible_Checkout_Fields_Plugin $plugin . |
| 19 | */ |
| 20 | public function __construct( $plugin ) { |
| 21 | |
| 22 | $this->plugin = $plugin; |
| 23 | |
| 24 | add_action( 'init', [ $this, 'init_polylang' ] ); |
| 25 | add_action( 'admin_init', [ $this, 'init_wpml' ] ); |
| 26 | } |
| 27 | |
| 28 | function init_polylang() { |
| 29 | if ( function_exists( 'pll_register_string' ) ) { |
| 30 | $settings = get_option( EditFieldsForm::SETTINGS_OPTION_NAME, [] ); |
| 31 | foreach ( $settings as $section ) { |
| 32 | if ( is_array( $section ) ) { |
| 33 | foreach ( $section as $field ) { |
| 34 | if ( isset( $field['label'] ) && $field['label'] !== '' ) { |
| 35 | pll_register_string( $field['label'], $field['label'], __( 'Flexible Checkout Fields', 'flexible-checkout-fields' ) ); |
| 36 | } |
| 37 | if ( isset( $field['placeholder'] ) && $field['placeholder'] !== '' ) { |
| 38 | pll_register_string( $field['placeholder'], $field['placeholder'], __( 'Flexible Checkout Fields', 'flexible-checkout-fields' ) ); |
| 39 | } |
| 40 | if ( isset( $field['default'] ) && $field['default'] !== '' ) { |
| 41 | pll_register_string( $field['default'], $field['default'], __( 'Flexible Checkout Fields', 'flexible-checkout-fields' ) ); |
| 42 | } |
| 43 | if ( isset( $field['options'] ) ) { |
| 44 | foreach ( $field['options'] as $option_data ) { |
| 45 | pll_register_string( $option_data['value'], $option_data['value'], __( 'Flexible Checkout Fields', 'flexible-checkout-fields' ) ); |
| 46 | } |
| 47 | } |
| 48 | if ( isset( $field['regex_message'] ) && $field['regex_message'] !== '' ) { |
| 49 | pll_register_string( $field['regex_message'], $field['regex_message'], __( 'Flexible Checkout Fields', 'flexible-checkout-fields' ) ); |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | function init_wpml() { |
| 58 | if ( function_exists( 'icl_register_string' ) ) { |
| 59 | $icl_language_code = defined( 'ICL_LANGUAGE_CODE' ) ? ICL_LANGUAGE_CODE : get_bloginfo( 'language' ); |
| 60 | $settings = get_option( EditFieldsForm::SETTINGS_OPTION_NAME, [] ); |
| 61 | foreach ( $settings as $section ) { |
| 62 | if ( is_array( $section ) ) { |
| 63 | foreach ( $section as $field ) { |
| 64 | if ( isset( $field['label'] ) && $field['label'] !== '' ) { |
| 65 | icl_register_string( 'flexible-checkout-fields', $field['label'], $field['label'], false, $icl_language_code ); |
| 66 | } |
| 67 | if ( isset( $field['placeholder'] ) && $field['placeholder'] !== '' ) { |
| 68 | icl_register_string( 'flexible-checkout-fields', $field['placeholder'], $field['placeholder'], false, $icl_language_code ); |
| 69 | } |
| 70 | if ( isset( $field['default'] ) && $field['default'] !== '' ) { |
| 71 | icl_register_string( 'flexible-checkout-fields', $field['default'], $field['default'], false, $icl_language_code ); |
| 72 | } |
| 73 | if ( isset( $field['options'] ) ) { |
| 74 | foreach ( $field['options'] as $option_data ) { |
| 75 | icl_register_string( 'flexible-checkout-fields', $option_data['value'], $option_data['value'], false, $icl_language_code ); |
| 76 | } |
| 77 | } |
| 78 | if ( isset( $field['regex_message'] ) && $field['regex_message'] !== '' ) { |
| 79 | icl_register_string( 'flexible-checkout-fields', $field['regex_message'], $field['regex_message'], false, $icl_language_code ); |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 |