WordPress.org

Support

Support » Plugins and Hacks » quick edit makes losing all meta data

quick edit makes losing all meta data

Viewing 2 replies - 1 through 2 (of 2 total)
  • at our website winnins.com we use the plugin and found it’s really valuable and useful to meet our needs. Recently bumped the same issue and added a quick fix to the plugin.
    The reason of losing meta tags when saving with quick edit is quite simple just take a look at the function hook_save_post()
    it assigns the meta values from the $POST variable but quick edit form doesn’t have any fields with meta values.
    Here’s how we fixed and proven to be a working solution:
    find this part in the function function hook_save_post($post_id)

    foreach($this->field_names as $field => $field_label) {
        //Get field data
        $field_id = "qtrans_meta_{$field}_{$lang}";
        $field_data = trim(str_replace('"', '', $_POST[$field_id]));
        $meta[$field][$lang] = $field_data;
    } //end of iterating over field names

    and add a condition to check if there’s $_POST data for the fields:

    foreach($this->field_names as $field => $field_label) {
        //Get field data
        $field_id = "qtrans_meta_{$field}_{$lang}";
        if (isset($_POST[$field_id])) { // fix to avoid losing metadata with quick edit
            $field_data = trim(str_replace('"', "'", $_POST[$field_id]));
            $meta[$field][$lang] = $field_data;
        }
    } //end of iterating over field names

    I hope it helps 🙂

    Thanks winnings.com 🙂 your solution is working fine!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘quick edit makes losing all meta data’ is closed to new replies.