function tdr_save_global_key_value_pair()
{
    // Initialize
    $tdr_product = new Thunder_Plugin_Products();
    // Setup request return info for client callback
    $return_array = array('message' => '', 'confirm_message' => '', 'confirm_request' => false, 'error' => '', 'confirmation_key' => '');
    // Set other defaults
    $keys_changed = false;
    $save_changes = false;
    $synch_changes = false;
    // Check javascript client script version
    if ($_POST['client_version'] != 0.1) {
        $return_array['error'] = 'Your browser has an old version of the page loaded. Please try refreshing your page or clearing your browser cache, then try again.';
    } else {
        // Data is already decoded
        // Do any wanted filtering
        $key_value_pairs = $_POST['key_value_json'];
        $key_value_pairs = stripslashes($key_value_pairs);
        $key_value_pairs = json_decode($key_value_pairs, true);
        if (empty($key_value_pairs)) {
            $return_array['error'] = 'There was a problem processing any data. Unless you intended to remove all fields and their values, this is bad.';
        } else {
            // Ensure meta_id is valid (exists)
            $meta_id = esc_html($_POST['meta_id']);
            $meta_array = $tdr_product->define_custom_meta_types();
            $meta_id_valid = false;
            foreach ($meta_array as $meta_entry) {
                if ($tdr_product->underscore($meta_entry['uuid']) == $meta_id) {
                    $meta_id_valid = true;
                }
            }
            if (!$meta_id_valid) {
                $return_array['error'] = 'The submission request contained tampered information.';
            } else {
                // Need to get post id for ajax calling post
                $post_id = $_POST['post_id'];
                $meta_value = get_post_meta($post_id, $meta_id, true);
                // Check if number or names of fields have changed
                $original_keys = get_option($meta_id . '_keys');
                $original_keys = array_keys($original_keys);
                $newest_keys = array_keys($key_value_pairs);
                if (count($original_keys) == count($newest_keys)) {
                    $key_difference = array_diff($newest_keys, $original_keys);
                    if (!empty($key_difference)) {
                        $keys_changed = true;
                    }
                } else {
                    $keys_changed = true;
                }
                if ($keys_changed) {
                    // Check for admin powers
                    if (!current_user_can('administrator')) {
                        $return_array['error'] = 'You are not authorized to add/remove fields. Your changes will be discarded.';
                    } else {
                        // Check for confirmation key
                        if (!isset($_POST['confirmation_key'])) {
                            $return_array['confirm_request'] = true;
                            $return_array['confirm_message'] = 'You have changed the name/number of fields. This will synchronize across other products. Are you sure you want to continue?';
                        } else {
                            $save_changes = true;
                            $synch_changes = true;
                        }
                    }
                } else {
                    // Proceed to save
                    $save_changes = true;
                }
                /**
                 * Save comparison points for current product
                 */
                if ($save_changes) {
                    // JSON Encode the meta
                    $new_meta_value = json_encode($key_value_pairs);
                    /* If there the new meta value is blank but an old value existed, delete it. */
                    if ('' == $new_meta_value && $meta_value) {
                        delete_post_meta($post_id, $meta_id, $meta_value);
                    } else {
                        update_post_meta($post_id, $meta_id, $new_meta_value);
                    }
                    $return_array['message'] = 'Your changes to this product have been saved';
                }
                /**
                 * Synchronize changes to fields to other products
                 */
                if (!$synch_changes) {
                } else {
                    $new_option_value = array_keys($key_value_pairs);
                    $new_option_value = array_map("strval", $new_option_value);
                    $new_option_array = array();
                    foreach ($new_option_value as $key) {
                        // Keys mapped to empty string
                        $new_option_array[$key] = "";
                    }
                    update_option($meta_id . '_keys', $new_option_array);
                    // Get information about key changes
                    $key_changes_list = $_POST['key_changes'];
                    $key_changes_list = stripslashes($key_changes_list);
                    $key_changes_list = json_decode($key_changes_list, true);
                    // List of key changes will be empty if all keys are new or all old keys are removed
                    // START Synchronize fields to other saved products
                    // The Query
                    $args = array('post_type' => 'tdr_product', 'posts_per_page' => -1, 'post__not_in' => array($post_id));
                    $the_query = new WP_Query($args);
                    // Import important comparison keys from wordpress options table
                    // Get serialized list of custom comparison keys from WP options -- false if not set
                    $comparison_keys = get_option($meta_id . '_keys', $default = array());
                    // The Loop
                    while ($the_query->have_posts()) {
                        $the_query->the_post();
                        global $post;
                        // Fetch current serialized key-value pair for tdr_product in the loop
                        $product_comparison_meta = get_post_meta($post->ID, $meta_id, true);
                        // Deserialize
                        $product_comparison_meta = json_decode($product_comparison_meta, true);
                        if (empty($product_comparison_meta)) {
                            // Make an empty array if not set
                            $product_comparison_meta = array();
                        }
                        // Access important keys from class attribute
                        $base_key_array = $tdr_product->fetch_custom_keys($meta_id);
                        // Change names of saved keys that were renamed
                        foreach ($key_changes_list as $original_key => $renamed_key) {
                            // Assign old key's value to renamed key
                            $product_comparison_meta[$renamed_key] = $product_comparison_meta[$original_key];
                            // Remove original key
                            unset($product_comparison_meta[$original_key]);
                        }
                        // Find saved values with important keys
                        $product_comparison_meta = array_intersect_key($product_comparison_meta, $base_key_array);
                        // Add any missing important keys
                        $merged_fields = $product_comparison_meta + $base_key_array;
                        // Because they are originally serialized by javascript, resaving them here will make them a bit different: e.g., no HTML entities
                        // Reserialize
                        $merged_fields = json_encode($merged_fields);
                        // Save
                        update_post_meta($post->ID, $meta_id, $merged_fields);
                    }
                    // Reset Post Data
                    wp_reset_postdata();
                    $return_array['message'] .= ' and synchronized to ' . $the_query->post_count . ' other products';
                    // END Synchronize fields to other saved products
                }
            }
        }
    }
    $return_json = json_encode($return_array);
    echo $return_json;
    die;
    // this is required to return a proper result
}