I18n-polylang.php
1 week ago
I18n-wpml.php
1 week ago
I18n.php
1 week ago
pods-admin-i18n.js
1 week ago
I18n-wpml.php
77 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Class Pods_I18n_WPML |
| 5 | */ |
| 6 | class Pods_I18n_WPML { |
| 7 | |
| 8 | public $languages = array(); |
| 9 | |
| 10 | /** |
| 11 | * Pods_I18n_WPML constructor. |
| 12 | */ |
| 13 | public function __construct() { |
| 14 | |
| 15 | $languages = apply_filters( 'wpml_active_languages', array() ); |
| 16 | if ( ! empty( $languages ) ) { |
| 17 | foreach ( $languages as $lang => $lang_data ) { |
| 18 | if ( isset( $lang_data['default_locale'] ) ) { |
| 19 | $locale = $lang_data['default_locale']; |
| 20 | $this->languages[] = $locale; |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | add_filter( 'pods_component_i18n_admin_data', array( $this, 'pods_component_i18n_admin_data' ) ); |
| 25 | add_filter( |
| 26 | 'pods_component_i18n_admin_ui_fields', array( |
| 27 | $this, |
| 28 | 'pods_component_i18n_admin_ui_fields', |
| 29 | ), 10, 2 |
| 30 | ); |
| 31 | } |
| 32 | |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * @param $data |
| 37 | * |
| 38 | * @return mixed |
| 39 | */ |
| 40 | public function pods_component_i18n_admin_data( $data ) { |
| 41 | |
| 42 | foreach ( $data as $lang => $field_data ) { |
| 43 | if ( in_array( $lang, $this->languages, true ) ) { |
| 44 | $data[ $lang ]['wpml'] = true; |
| 45 | } else { |
| 46 | $data[ $lang ]['wpml'] = false; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | return $data; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * @param $fields |
| 55 | * @param $data |
| 56 | * |
| 57 | * @return mixed |
| 58 | */ |
| 59 | public function pods_component_i18n_admin_ui_fields( $fields, $data ) { |
| 60 | |
| 61 | $fields['manage']['wpml'] = array( |
| 62 | 'label' => __( 'WPML', 'pods' ), |
| 63 | 'type' => 'boolean', |
| 64 | /* |
| 65 | 'options' => array( |
| 66 | 'text_allow_html' => 1, |
| 67 | 'text_allowed_html_tags' => 'br a', |
| 68 | )*/ |
| 69 | ); |
| 70 | |
| 71 | return $fields; |
| 72 | } |
| 73 | |
| 74 | } |
| 75 | |
| 76 | new Pods_I18n_WPML(); |
| 77 |