Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts
  • in reply to: [0.9.9.6] Add more problem #5960
    nakanaa
    Member

    @Steve any ETA on when we will the patched version be released? I’m having the same problem with Piklist 0.9.9.7

    BTW, what is the correct way to filter/edit post metadata before it’s saved in the DB?
    In native WP there’s wp_insert_post_data, but I tried using it but the $data array doesn’t have any of the metadata included. Where should I look?

    I made a temporary fix for this issue, but I had to edit Piklist plugin files because I couldn’t figure how to filter the metadata. If anyone is interested, here’s how I fixed it:

    First defined this somewhere:

    
    /*
     * Custom fix for: https://piklist.com/support/topic/0-9-9-6-add-more-problem/
     *
     * TODO: Remove when fixed upstream!
     */
    function fix_keys(&$value) {
        if (is_array($value)) {
            // Check whether the array has numeric keys
            // From: http://stackoverflow.com/a/4254008
            if (!(count(array_filter(array_keys($value), 'is_string')) > 0)) {
                $value = array_values($value);
            }
            foreach ($value as &$item) {
                fix_keys($item);
            }
        }
    }
    

    Then at piklist\includes\class-piklist-form.php after line 3111 (beginning of the else clause) I added this:

    
    if ($field['type'] === 'group' && is_array($field['request_value'])) {
        fix_keys($field['request_value']);
    }
    

    No idea if it’s optimal in any way, but at least everything seems to work now (only did some quick tests).

Viewing 1 post (of 1 total)