本文整理汇总了PHP中MS_Model_Membership::reset_field方法的典型用法代码示例。如果您正苦于以下问题:PHP MS_Model_Membership::reset_field方法的具体用法?PHP MS_Model_Membership::reset_field怎么用?PHP MS_Model_Membership::reset_field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MS_Model_Membership
的用法示例。
在下文中一共展示了MS_Model_Membership::reset_field方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: serialize_membership
/**
* Translate the plugin settings before they are saved to DB.
*
* @since 1.0.1.0
*
* @param array $obj The serialized data collection.
* @param MS_Model_Membership $model The source object.
* @return array The serialized data collection.
*/
public function serialize_membership($data, $model)
{
if ($this->current_lang == $this->default_lang) {
return $data;
}
// Save the translated values before resetting the model.
$tr_name = $data['name'];
$tr_description = $data['description'];
// Reset the values to Default language.
$data['name'] = $model->reset_field('name');
$data['description'] = $model->reset_field('description');
// Store translations via WPML.
if (function_exists('icl_add_string_translation')) {
$string_name = 'ms-mem-name-' . $model->id;
do_action('wpml_register_single_string', self::CONTEXT, $string_name, $data['name']);
$string_id = icl_get_string_id($data['name'], self::CONTEXT, $string_name);
if ($string_id) {
icl_add_string_translation($string_id, $this->current_lang, $tr_name, ICL_TM_COMPLETE);
}
$string_name = 'ms-mem-description-' . $model->id;
do_action('wpml_register_single_string', self::CONTEXT, $string_name, $data['description']);
$string_id = icl_get_string_id($data['description'], self::CONTEXT, $string_name);
if ($string_id) {
icl_add_string_translation($string_id, $this->current_lang, $tr_description, ICL_TM_COMPLETE);
}
}
return $data;
}