function icl_st_update_string_actions($context, $name, $old_value, $new_value, $force_complete = false) { global $wpdb; if ($new_value != $old_value) { $string = $wpdb->get_row($wpdb->prepare("SELECT id, value, status FROM {$wpdb->prefix}icl_strings WHERE context=%s AND name=%s", $context, $name)); if (!$string) { icl_register_string($context, $name, $new_value); return; } $wpdb->update($wpdb->prefix . 'icl_strings', array('value' => $new_value), array('id' => $string->id)); if ($string->status == ICL_TM_COMPLETE || $string->status == ICL_STRING_TRANSLATION_PARTIAL) { /*if $force_complete is set to true, all translations will be marked as complete even if a string's original value is updated This is currently only used to allow editing tagline and blogname for one language, without influencing other languages */ if ($force_complete) { $new_status = ICL_TM_COMPLETE; } else { $new_status = ICL_TM_NEEDS_UPDATE; } $wpdb->update($wpdb->prefix . 'icl_string_translations', array('status' => $new_status), array('string_id' => $string->id)); $wpdb->update($wpdb->prefix . 'icl_strings', array('status' => $new_status), array('id' => $string->id)); } if ($context == 'Widgets' && $new_value) { if (0 === strpos($name, 'widget title - ')) { icl_rename_string('Widgets', 'widget title - ' . md5($old_value), 'widget title - ' . md5($new_value)); } elseif (0 === strpos($name, 'widget body - ')) { icl_rename_string('Widgets', 'widget body - ' . md5($old_value), 'widget body - ' . md5($new_value)); } } } }
function icl_st_update_string_actions($context, $name, $old_value, $new_value) { global $wpdb; if ($new_value != $old_value) { $string = $wpdb->get_row($wpdb->prepare("SELECT id, value, status FROM {$wpdb->prefix}icl_strings WHERE context=%s AND name=%s", $context, $name)); if (!$string) { icl_register_string($context, $name, $new_value); return; } $wpdb->update($wpdb->prefix . 'icl_strings', array('value' => $new_value), array('id' => $string->id)); if ($string->status == ICL_STRING_TRANSLATION_COMPLETE || $string->status == ICL_STRING_TRANSLATION_PARTIAL) { $wpdb->update($wpdb->prefix . 'icl_string_translations', array('status' => ICL_STRING_TRANSLATION_NEEDS_UPDATE), array('string_id' => $string->id)); $wpdb->update($wpdb->prefix . 'icl_strings', array('status' => ICL_STRING_TRANSLATION_NEEDS_UPDATE), array('id' => $string->id)); } if ($context == 'Widgets' && $new_value) { if (0 === strpos($name, 'widget title - ')) { icl_rename_string('Widgets', 'widget title - ' . md5($old_value), 'widget title - ' . md5($new_value)); } elseif (0 === strpos($name, 'widget body - ')) { icl_rename_string('Widgets', 'widget body - ' . md5($old_value), 'widget body - ' . md5($new_value)); } } } }