예제 #1
0
function qtranxf_convert_database_postmeta($action)
{
    global $wpdb;
    $result = $wpdb->get_results('SELECT meta_id, meta_value FROM ' . $wpdb->postmeta);
    if (!$result) {
        return;
    }
    switch ($action) {
        case 'b_only':
            foreach ($result as $row) {
                if (!qtranxf_isMultilingual($row->meta_value)) {
                    continue;
                }
                //if(!preg_match('/(<!--:[a-z]{2}-->|\[:[a-z]{2}\])/im',$row->meta_value)) continue;
                $value = maybe_unserialize($row->meta_value);
                $value_converted = qtranxf_convert_to_b_deep($value);
                $value_serialized = maybe_serialize($value_converted);
                if ($value_serialized === $row->meta_value) {
                    continue;
                }
                $wpdb->query($wpdb->prepare('UPDATE ' . $wpdb->postmeta . ' set meta_value = %s WHERE meta_id = %d', $value_serialized, $row->meta_id));
                //$wpdb->query('UPDATE '.$wpdb->postmeta.' set meta_value = "'.mysql_real_escape_string($value_serialized).'" WHERE meta_id='.$row->meta_id);
            }
            break;
        case 'c_dual':
            foreach ($result as $row) {
                if (!qtranxf_isMultilingual($row->meta_value)) {
                    continue;
                }
                //if(!preg_match('/(<!--:[a-z]{2}-->|\[:[a-z]{2}\])/im',$row->meta_value)) continue;
                $value = maybe_unserialize($row->meta_value);
                $value_converted = qtranxf_convert_to_b_no_closing_deep($value);
                $value_serialized = maybe_serialize($value_converted);
                if ($value_serialized === $row->meta_value) {
                    continue;
                }
                $wpdb->query($wpdb->prepare('UPDATE ' . $wpdb->postmeta . ' set meta_value = %s WHERE meta_id = %d', $value_serialized, $row->meta_id));
                //$wpdb->query('UPDATE '.$wpdb->postmeta.' set meta_value = "'.mysql_real_escape_string($value_serialized).'" WHERE meta_id='.$row->meta_id);
            }
            break;
        default:
            break;
    }
}
예제 #2
0
function qtranxf_convert_database_postmeta($action)
{
    global $wpdb;
    $result = $wpdb->get_results('SELECT meta_id, meta_value FROM ' . $wpdb->postmeta);
    if (!$result) {
        return;
    }
    switch ($action) {
        case 'b_only':
            foreach ($result as $row) {
                if (!qtranxf_isMultilingual($row->meta_value)) {
                    continue;
                }
                $value = maybe_unserialize($row->meta_value);
                $value_converted = qtranxf_convert_to_b_deep($value);
                $value_serialized = maybe_serialize($value_converted);
                if ($value_serialized === $row->meta_value) {
                    continue;
                }
                $wpdb->query($wpdb->prepare('UPDATE ' . $wpdb->postmeta . ' set meta_value = %s WHERE meta_id = %d', $value_serialized, $row->meta_id));
            }
            break;
        case 'c_dual':
            foreach ($result as $row) {
                if (!qtranxf_isMultilingual($row->meta_value)) {
                    continue;
                }
                $value = maybe_unserialize($row->meta_value);
                $value_converted = qtranxf_convert_to_b_no_closing_deep($value);
                $value_serialized = maybe_serialize($value_converted);
                if ($value_serialized === $row->meta_value) {
                    continue;
                }
                $wpdb->query($wpdb->prepare('UPDATE ' . $wpdb->postmeta . ' set meta_value = %s WHERE meta_id = %d', $value_serialized, $row->meta_id));
            }
            break;
        default:
            break;
    }
}