/** * Conditionally set some default values for event related custom fields translation. * * @return bool `false` if defaults were already set, `true` otherwise. */ public function set_defaults() { // make this check again has the action is triggered many times in a request lifecycle if ($this->has_set_defaults()) { return false; } $fields = $this->get_default_copy_fields(); foreach ($fields as $field) { $this->sitepress->core_tm()->settings['custom_fields_translation'][$field] = WPML_COPY_CUSTOM_FIELD; } // remove the method to avoid infinite loops remove_action('icl_save_settings', array($this, 'set_defaults')); // the Translation Management plugin might not be active on this // installation, save this option only if Translation Management is active. $translation_management = $this->sitepress->core_tm(); $tm_is_active = !empty($translation_management) && is_a($translation_management, 'TranslationManagement'); if ($tm_is_active) { $translation_management->save_settings(); Tribe__Settings_Manager::set_option($this->defaults_option_name, true); return true; } return false; }